about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-x351
-rw-r--r--shutdown.d/10-sv-stop.sh3
-rw-r--r--shutdown.d/20-rc-shutdown.sh1
-rw-r--r--shutdown.d/30-seedrng.sh4
-rw-r--r--shutdown.d/40-hwclock.sh3
-rw-r--r--shutdown.d/50-wtmp.sh1
-rw-r--r--shutdown.d/60-udev.sh4
-rw-r--r--shutdown.d/70-pkill.sh5
-rw-r--r--shutdown.d/80-filesystems.sh14
-rw-r--r--shutdown.d/90-kexec.sh7
10 files changed, 45 insertions, 48 deletions
diff --git a/3 b/3
index 469d437..0bd452a 100755
--- a/3
+++ b/3
@@ -6,52 +6,7 @@ PATH=/usr/bin:/usr/sbin
 . /etc/runit/functions
 detect_virt
 [ -r /etc/rc.conf ] && . /etc/rc.conf
-
 echo
-msg "Waiting for services to stop..."
-sv force-stop /var/service/*
-sv exit /var/service/*
-
-[ -x /etc/rc.shutdown ] && /etc/rc.shutdown
-
-if [ -z "$VIRTUALIZATION" ]; then
-    msg "Saving random number generator seed..."
-    seedrng
-fi
-
-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
-
-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
+for f in /etc/runit/shutdown.d/*.sh; do
+	[ -r $f ] && . $f
+done
diff --git a/shutdown.d/10-sv-stop.sh b/shutdown.d/10-sv-stop.sh
new file mode 100644
index 0000000..6d2efd0
--- /dev/null
+++ b/shutdown.d/10-sv-stop.sh
@@ -0,0 +1,3 @@
+msg "Waiting for services to stop..."
+sv force-stop /var/service/*
+sv exit /var/service/*
diff --git a/shutdown.d/20-rc-shutdown.sh b/shutdown.d/20-rc-shutdown.sh
new file mode 100644
index 0000000..1df105b
--- /dev/null
+++ b/shutdown.d/20-rc-shutdown.sh
@@ -0,0 +1 @@
+[ -x /etc/rc.shutdown ] && /etc/rc.shutdown
diff --git a/shutdown.d/30-seedrng.sh b/shutdown.d/30-seedrng.sh
new file mode 100644
index 0000000..3bcb78f
--- /dev/null
+++ b/shutdown.d/30-seedrng.sh
@@ -0,0 +1,4 @@
+if [ -z "$VIRTUALIZATION" ]; then
+    msg "Saving random number generator seed..."
+    seedrng
+fi
diff --git a/shutdown.d/40-hwclock.sh b/shutdown.d/40-hwclock.sh
new file mode 100644
index 0000000..490ad73
--- /dev/null
+++ b/shutdown.d/40-hwclock.sh
@@ -0,0 +1,3 @@
+if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then
+    hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
+fi
diff --git a/shutdown.d/50-wtmp.sh b/shutdown.d/50-wtmp.sh
new file mode 100644
index 0000000..d730013
--- /dev/null
+++ b/shutdown.d/50-wtmp.sh
@@ -0,0 +1 @@
+halt -w
diff --git a/shutdown.d/60-udev.sh b/shutdown.d/60-udev.sh
new file mode 100644
index 0000000..dd42ff7
--- /dev/null
+++ b/shutdown.d/60-udev.sh
@@ -0,0 +1,4 @@
+if [ -z "$VIRTUALIZATION" ]; then
+    msg "Stopping udev..."
+    udevadm control --exit
+fi
diff --git a/shutdown.d/70-pkill.sh b/shutdown.d/70-pkill.sh
new file mode 100644
index 0000000..e396cb0
--- /dev/null
+++ b/shutdown.d/70-pkill.sh
@@ -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
diff --git a/shutdown.d/80-filesystems.sh b/shutdown.d/80-filesystems.sh
new file mode 100644
index 0000000..95dcce4
--- /dev/null
+++ b/shutdown.d/80-filesystems.sh
@@ -0,0 +1,14 @@
+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
+fi
diff --git a/shutdown.d/90-kexec.sh b/shutdown.d/90-kexec.sh
new file mode 100644
index 0000000..8b3eb93
--- /dev/null
+++ b/shutdown.d/90-kexec.sh
@@ -0,0 +1,7 @@
+if [ -z "$VIRTUALIZATION" ]; then
+    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