define-alpine-the-sequel/runit/scripts/3

44 lines
943 B
Text
Raw Permalink Normal View History

2023-02-02 21:28:47 +00:00
#!/bin/sh
PATH=/bin:/usr/bin:/usr/sbin:/sbin
. /etc/runit/functions
detect_virt
[ -r /etc/rc.conf ] && . /etc/rc.conf
echo
msg "Waiting for services to stop..."
sv force-stop /etc/service/*
sv exit /etc/service/*
[ -x /etc/rc.shutdown ] && /etc/rc.shutdown
if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
fi
halt -w # for wtmp
if [ -z "$VIRTUALIZATION" ]; then
msg "Stopping udev..."
udevadm control --exit
fi
if [ -z "$VIRTUALIZATION" ]; then
msg "Unmounting filesystems, disabling swap..."
swapoff -a
umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
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