diff options
| author | emmett1 <emmett1.2miligrams@protonmail.com> | 2025-09-10 08:14:17 +0800 |
|---|---|---|
| committer | emmett1 <emmett1.2miligrams@protonmail.com> | 2025-09-10 08:14:17 +0800 |
| commit | 5b06140deda36925abe23115dc9affab61527279 (patch) | |
| tree | e6f88bd0fd056d74af6a2c4090372e355c97fba3 /repos/core/initscripts/rc.shutdown | |
| parent | d1304e447af44d2a455125866b9ffd838909416a (diff) | |
| download | alicelinux-5b06140deda36925abe23115dc9affab61527279.tar.gz alicelinux-5b06140deda36925abe23115dc9affab61527279.zip | |
initscripts: updated to 20250910
Diffstat (limited to 'repos/core/initscripts/rc.shutdown')
| -rwxr-xr-x[-rw-r--r--] | repos/core/initscripts/rc.shutdown | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/repos/core/initscripts/rc.shutdown b/repos/core/initscripts/rc.shutdown index 68b47022..255c4b5a 100644..100755 --- a/repos/core/initscripts/rc.shutdown +++ b/repos/core/initscripts/rc.shutdown @@ -1,27 +1,58 @@ #!/bin/sh -echo "shutting down" +echo "> Shutting down system..." if [ -x /etc/rc.shutdown.local ]; then - /etc/rc.shutdown.local + echo "> Running local shutdown scripts..." + /etc/rc.shutdown.local fi -if [ "$(command -v udevadm)" ]; then - udevadm control --exit +if command -v udevadm >/dev/null 2>&1; then + echo "> Stopping udev..." + udevadm control --exit fi -sv down /var/service/* -dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null -hwclock -w -u -kill -s TERM -1 +echo "> Stopping all services..." +sv force-stop /var/service/* 2>/dev/null + +sleep 1 + +if [ -w /var/lib/random-seed ]; then + echo "> Saving random seed..." + dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null +fi + +if [ -e /dev/rtc ] || [ -e /dev/rtc0 ]; then + echo "> Syncing hardware clock..." + hwclock -w -u 2>/dev/null +fi + +echo "> Terminating processes..." +kill -s TERM -1 2>/dev/null sleep 2 -kill -s KILL -1 -swapoff -a -ip link set lo down -umount -a -r -t noproc -mount -o remount,ro / + +kill -s KILL -1 2>/dev/null +sleep 1 + +echo "> Disabling swap..." +swapoff -a 2>/dev/null + +echo "> Bringing down network..." +ip link set lo down 2>/dev/null + +for iface in $(ip link show | grep '^[0-9]' | awk -F: '{print $2}' | tr -d ' ' | grep -v '^lo$'); do + ip link set "$iface" down 2>/dev/null +done + +echo "> Unmounting filesystems..." +umount -a -r -t noproc 2>/dev/null + +echo "> Remounting root as read-only..." +mount -o remount,ro / 2>/dev/null + +echo "> Syncing filesystems..." sync + sleep 1 -wait -echo bye +echo "> Shutdown complete. Bye!" |