Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
20a1ca16bc | |||
82bf65d4fa | |||
f8a8bc673b |
47
3
47
3
@@ -11,49 +11,10 @@ if [ -e /run/runit/reboot ]; then
|
||||
chmod 100 /run/runit/reboot
|
||||
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
|
||||
|
||||
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 )
|
||||
for f in /etc/runit/shutdown-services/*.sh; do
|
||||
[ -r $f ] && . $f
|
||||
done
|
||||
|
||||
if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then
|
||||
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
|
||||
msg "Stage 3 completed."
|
||||
|
29
Makefile
29
Makefile
@@ -6,27 +6,26 @@ all:
|
||||
$(CC) $(CFLAGS) pause.c -o pause $(LDFLAGS)
|
||||
|
||||
install:
|
||||
install -d ${DESTDIR}${PREFIX}/bin
|
||||
install -d ${DESTDIR}${PREFIX}/lib/runit-artix/bin
|
||||
install -m755 pause ${DESTDIR}${PREFIX}/bin/pause
|
||||
install -m755 modules-load ${DESTDIR}${PREFIX}/bin/modules-load
|
||||
install -m755 zzz ${DESTDIR}${PREFIX}/bin/zzz
|
||||
install -m755 halt ${DESTDIR}${PREFIX}/lib/runit-artix/bin/halt
|
||||
install -m755 pause ${DESTDIR}${PREFIX}/lib/runit-artix/bin/pause
|
||||
install -m755 shutdown ${DESTDIR}${PREFIX}/lib/runit-artix/bin/shutdown
|
||||
install -m755 modules-load ${DESTDIR}${PREFIX}/lib/runit-artix/bin/modules-load
|
||||
install -m755 zzz ${DESTDIR}${PREFIX}/lib/runit-artix/bin/zzz
|
||||
ln -sf halt ${DESTDIR}${PREFIX}/lib/runit-artix/bin/poweroff
|
||||
ln -sf halt ${DESTDIR}${PREFIX}/lib/runit-artix/bin/reboot
|
||||
install -d ${DESTDIR}${PREFIX}/share/man/man1
|
||||
install -m644 pause.1 ${DESTDIR}${PREFIX}/share/man/man1
|
||||
install -d ${DESTDIR}${PREFIX}/share/man/man8
|
||||
install -m644 zzz.8 ${DESTDIR}${PREFIX}/share/man/man8/zzz-runit.8
|
||||
install -m644 shutdown.8 ${DESTDIR}${PREFIX}/share/man/man8/shutdown-runit.8
|
||||
install -m644 halt.8 ${DESTDIR}${PREFIX}/share/man/man8/halt-runit.8
|
||||
install -m644 zzz.8 ${DESTDIR}${PREFIX}/share/man/man8/zzz.8
|
||||
install -m644 modules-load.8 ${DESTDIR}${PREFIX}/share/man/man8
|
||||
ln -sf halt-runit.8 ${DESTDIR}${PREFIX}/share/man/man8/poweroff-runit.8
|
||||
ln -sf halt-runit.8 ${DESTDIR}${PREFIX}/share/man/man8/reboot-runit.8
|
||||
install -d ${DESTDIR}/etc/runit/sv
|
||||
install -d ${DESTDIR}/etc/runit/runsvdir
|
||||
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 shutdown-services/*.sh ${DESTDIR}/etc/runit/shutdown-services
|
||||
install -m755 ${SCRIPTS} ${DESTDIR}/etc/runit
|
||||
install -m644 functions $(DESTDIR)/etc/runit
|
||||
install -m644 crypt.awk ${DESTDIR}/etc/runit
|
||||
@@ -38,7 +37,19 @@ install:
|
||||
cp -R --no-dereference --preserve=mode,links -v runsvdir/* ${DESTDIR}/etc/runit/runsvdir/
|
||||
cp -R --no-dereference --preserve=mode,links -v services/* ${DESTDIR}/etc/runit/sv/
|
||||
|
||||
install_sysv:
|
||||
install -d ${DESTDIR}${PREFIX}/bin
|
||||
ln -sf runit-init ${DESTDIR}${PREFIX}/bin/init
|
||||
ln -sf ${PREFIX}/lib/runit-artix/bin/halt ${DESTDIR}${PREFIX}/bin/halt
|
||||
ln -sf ${PREFIX}/lib/runit-artix/bin/shutdown ${DESTDIR}${PREFIX}/bin/shutdown
|
||||
ln -sf halt ${DESTDIR}${PREFIX}/bin/poweroff
|
||||
ln -sf halt ${DESTDIR}${PREFIX}/bin/reboot
|
||||
install -m644 shutdown.8 ${DESTDIR}${PREFIX}/share/man/man8/shutdown.8
|
||||
install -m644 halt.8 ${DESTDIR}${PREFIX}/share/man/man8/halt.8
|
||||
ln -sf halt.8 ${DESTDIR}${PREFIX}/share/man/man8/poweroff.8
|
||||
ln -sf halt.8 ${DESTDIR}${PREFIX}/share/man/man8/reboot.8
|
||||
|
||||
clean:
|
||||
-rm -f halt pause
|
||||
|
||||
.PHONY: all install clean
|
||||
.PHONY: all install install_sysv clean
|
||||
|
3
shutdown-services/00-stop-services.sh
Normal file
3
shutdown-services/00-stop-services.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
msg "Waiting for services to stop..."
|
||||
sv force-stop /run/runit/service/*
|
||||
sv exit /run/runit/service/*
|
2
shutdown-services/01-random-seed.sh
Normal file
2
shutdown-services/01-random-seed.sh
Normal 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 )
|
6
shutdown-services/02-hwclock.sh
Normal file
6
shutdown-services/02-hwclock.sh
Normal 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
|
4
shutdown-services/03-stop-udev.sh
Normal file
4
shutdown-services/03-stop-udev.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
if [ -z "$VIRTUALIZATION" ]; then
|
||||
msg "Stopping udev..."
|
||||
udevadm control --exit
|
||||
fi
|
5
shutdown-services/04-killall.sh
Normal file
5
shutdown-services/04-killall.sh
Normal 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
|
8
shutdown-services/97-mount-ro.sh
Normal file
8
shutdown-services/97-mount-ro.sh
Normal 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
|
9
shutdown-services/98-deactivate-crypt.sh
Normal file
9
shutdown-services/98-deactivate-crypt.sh
Normal 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
|
Reference in New Issue
Block a user