diff options
author | Cem Keylan <cem@ckyln.com> | 2020-01-13 11:37:16 +0300 |
---|---|---|
committer | Cem Keylan <cem@ckyln.com> | 2020-01-13 11:37:16 +0300 |
commit | 38a2e3f0ce51f335c63bf77646a827e216fc3025 (patch) | |
tree | 98dfc86e67ecbcf0afe992ebdc45246d93b7fc83 /rc.shutdown | |
parent | f4ecd3b5368a6588d797a59b0c6d49f79d9c70de (diff) | |
download | init-38a2e3f0ce51f335c63bf77646a827e216fc3025.tar.gz |
allow user hooks and make it more portable0.4.0
Diffstat (limited to 'rc.shutdown')
-rwxr-xr-x | rc.shutdown | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/rc.shutdown b/rc.shutdown index f47fdf7..83b6572 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -1,48 +1,53 @@ #!/bin/sh . /etc/init/rc.conf +. INITDIR/rc.lib -main() { - PATH=/sbin:/bin:/usr/sbin:/usr/bin +PATH=/sbin:/bin:/usr/sbin:/usr/bin - log "Waiting for services to stop..."; { - sv -w196 force-stop /var/service/* - sv exit /var/service/* - } +out "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 - } +out "Running pre shutdown hooks..."; { + run_hooks /etc/init/*.pre.shutdown +} - halt -w +out "Saving random seed..."; { + dd count=1 bs=512 if=/dev/random of=/var/random.seed +} - log "Sending TERM signal to all processes..."; { - killall5 -TERM - sleep 1 - } +halt -w - log "Sending KILL signal to all processes..."; { - killall5 -KILL - } +out "Sending TERM signal to all processes..."; { + killall5 -TERM + sleep 1 +} - log "Unmounting filesystems and disabling swap..." \ - "Remounting rootfs as readonly"; { - swapoff -a - umount -rat nosysfs,noproc,nodevtmpfs,notmpfs - mount -o remount,ro / +out "Sending KILL signal to all processes..."; { + killall5 -KILL +} - sync - } +out "Unmounting filesystems and disabling swap..." +out "Remounting rootfs as readonly"; { + swapoff -a + umount -rat nosysfs,noproc,nodevtmpfs,notmpfs + mount -o remount,ro / - 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 - } + sync +} + +out "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 +out "Running post shutdown hooks..."; { + run_hooks /etc/rc.d/*.post.shutdown +} |