2 Commits

9 changed files with 43 additions and 43 deletions

47
3
View File

@@ -11,49 +11,10 @@ if [ -e /run/runit/reboot ]; then
chmod 100 /run/runit/reboot chmod 100 /run/runit/reboot
fi fi
echo
msg "Waiting for services to stop..."
sv force-stop /run/runit/service/*
sv exit /run/runit/service/*
[ -x /etc/runit/rc.shutdown ] && /etc/runit/rc.shutdown [ -x /etc/runit/rc.shutdown ] && /etc/runit/rc.shutdown
msg "Saving random seed..." for f in /etc/runit/shutdown-services/*.sh; do
( 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 ) [ -r $f ] && . $f
done
if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then msg "Stage 3 completed."
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

View File

@@ -26,7 +26,9 @@ install:
install -d ${DESTDIR}/etc/runit/sv install -d ${DESTDIR}/etc/runit/sv
install -d ${DESTDIR}/etc/runit/runsvdir install -d ${DESTDIR}/etc/runit/runsvdir
install -d ${DESTDIR}/etc/runit/core-services install -d ${DESTDIR}/etc/runit/core-services
install -d ${DESTDIR}/etc/runit/shutdown-services
install -m644 core-services/*.sh ${DESTDIR}/etc/runit/core-services install -m644 core-services/*.sh ${DESTDIR}/etc/runit/core-services
install -m644 shutdown-services/*.sh ${DESTDIR}/etc/runit/shutdown-services
install -m755 ${SCRIPTS} ${DESTDIR}/etc/runit install -m755 ${SCRIPTS} ${DESTDIR}/etc/runit
install -m644 functions $(DESTDIR)/etc/runit install -m644 functions $(DESTDIR)/etc/runit
install -m644 crypt.awk ${DESTDIR}/etc/runit install -m644 crypt.awk ${DESTDIR}/etc/runit

View File

@@ -0,0 +1,3 @@
msg "Waiting for services to stop..."
sv force-stop /run/runit/service/*
sv exit /run/runit/service/*

View File

@@ -0,0 +1,2 @@
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 )

View File

@@ -0,0 +1,6 @@
if [ -z "$VIRTUALIZATION" ] && [ -n "$HARDWARECLOCK" ]; then
msg "Saving hardware clock..."
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
fi
halt -w # for utmp

View File

@@ -0,0 +1,4 @@
if [ -z "$VIRTUALIZATION" ]; then
msg "Stopping udev..."
udevadm control --exit
fi

View File

@@ -0,0 +1,5 @@
msg "Sending TERM signal to processes..."
pkill --inverse -s0,1 -TERM
sleep 1
msg "Sending KILL signal to processes..."
pkill --inverse -s0,1 -KILL

View File

@@ -0,0 +1,8 @@
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

View File

@@ -0,0 +1,9 @@
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