#!/bin/sh . /etc/init/rc.conf main() { PATH=/sbin:/bin:/usr/sbin:/usr/bin log "Waiting for services to stop..."; { sv -w196 force-stop /var/service/* sv exit /var/service/* } log "Saving random seed..."; { dd count=1 bs=512 if=/dev/random of=/var/random.seed } halt -w log "Sending TERM signal to all processes..."; { killall5 -TERM sleep 1 } log "Sending KILL signal to all processes..."; { killall5 -KILL } log "Unmounting filesystems and disabling swap..." \ "Remounting rootfs as readonly"; { swapoff -a umount -rat nosysfs,noproc,nodevtmpfs,notmpfs mount -o remount,ro / sync } log "Deactivating dmcrypt devices (if any exist)."; { [ -x /bin/cryptsetup ] && [ -x /bin/dmsetup ] && { dmsetup ls --target crypt \ --exec "dmsetup info -c --noheadings -o open,name" | while read -r drive; do [ "${drive%%:*}" = "0" ] && cryptsetup close "${drive##*:}" done } } } main