diff options
Diffstat (limited to 'core/runit/3')
| -rw-r--r-- | core/runit/3 | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/core/runit/3 b/core/runit/3 new file mode 100644 index 0000000..19540cd --- /dev/null +++ b/core/runit/3 @@ -0,0 +1,54 @@ +#!/bin/sh +# /etc/runit/3 - rawnix system shutdown + +exec 2>&1 +PATH=/sbin:/bin:/usr/sbin:/usr/bin +export PATH +stty onlcr 2>/dev/null + +printf '\nrawnix is shutting down...\n\n' + +printf 'Stopping services...\n' +sv force-stop /service/* 2>/dev/null +sv exit /service/* 2>/dev/null + +[ -x /etc/rc.shutdown ] && /etc/rc.shutdown + +printf 'Saving system clock...\n' +hwclock --systohc 2>/dev/null + +printf 'Saving urandom seed...\n' +mkdir -p /var/lib/random +chmod 700 /var/lib/random +dd if=/dev/urandom of=/var/lib/random/seed bs=512 count=1 2>/dev/null +chmod 600 /var/lib/random/seed + +printf 'Sending TERM signal...\n' +kill -TERM -1 2>/dev/null +sleep 2 + +printf 'Sending KILL signal...\n' +kill -KILL -1 2>/dev/null +sleep 1 + +printf 'Unmounting filesystems...\n' +sync +umount -a -d -r -t nosysfs,noproc,nodevtmpfs,notmpfs 2>/dev/null + +printf 'Closing LUKS volumes...\n' +if [ -x /sbin/cryptsetup ] && [ -f /etc/crypttab ]; then + while IFS= read -r line; do + case "$line" in ''|\#*) continue ;; esac + name="${line%% *}" + cryptsetup close "$name" 2>/dev/null + done < /etc/crypttab +fi + +printf 'Remounting root read-only...\n' +sync +mount -o remount,ro / 2>/dev/null + +swapoff -a 2>/dev/null + +printf 'Shutdown complete.\n' +exit 0 |
