#!/bin/sh # vim: set ts=4 sw=4 et: PATH=/usr/bin:/usr/sbin . /etc/runit/functions detect_virt [ -r /etc/rc.conf ] && . /etc/rc.conf if [ -e /run/runit/reboot ]; then chmod 100 /run/runit/reboot fi echo msg "Waiting for services to stop..." sv force-stop /var/service/* sv exit /var/service/* [ -x /etc/rc.shutdown ] && /etc/rc.shutdown msg "Saving random seed..." ( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 ) if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)} fi halt -w # for utmp if [ -z "$VIRTUALIZATION" ]; then msg "Stopping udev..." udevadm control --exit fi msg "Sending TERM signal to processes..." pkill --inverse -s0,1 -TERM sleep 1 msg "Sending KILL signal to processes..." pkill --inverse -s0,1 -KILL if [ -z "$VIRTUALIZATION" ]; then msg "Unmounting filesystems, disabling swap..." swapoff -a umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs msg "Remounting rootfs read-only..." mount -o remount,ro / fi sync if [ -z "$VIRTUALIZATION" ]; then deactivate_vgs deactivate_crypt if [ -e /run/runit/reboot ] && command -v kexec >/dev/null; then msg "Triggering kexec..." kexec -e 2>/dev/null # not reached when kexec was successful. fi fi