aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-05-16 11:53:02 +0300
committerCem Keylan <cem@ckyln.com>2020-05-16 11:53:02 +0300
commitb8b9c52a05f77b72a9ecfcf7d7759b61fa27bf80 (patch)
tree939e08b8913a77a33a87d52cdb55c071e4c4efe4
parent5deb47cfbb7bcd994bb7295637dc5e85187ce1cb (diff)
downloadinit-b8b9c52a05f77b72a9ecfcf7d7759b61fa27bf80.tar.gz
init: multiple changes
- kill runit services only if sv is available on the system - add run_hook function - add early-boot hook
-rwxr-xr-xrc.boot10
-rw-r--r--rc.lib9
-rwxr-xr-xrc.shutdown14
3 files changed, 18 insertions, 15 deletions
diff --git a/rc.boot b/rc.boot
index b9e7e14..c02d4c2 100755
--- a/rc.boot
+++ b/rc.boot
@@ -71,7 +71,8 @@ out "Mounting all local filesystems..."; {
mount -at nosysfs,nonfs,nonfs4,nosmbfs,nocifs -O no_netdev ||
shell
}
-}
+
+run_hook early-boot
out "Enabling swap..."; {
swapon -a || shell
@@ -126,12 +127,7 @@ command -v udevd >/dev/null &&
udevadm control --exit
-out "Running boot hooks..."
-set +f
-for file in /etc/init/*.boot ; do
- [ -f "$file" ] && \
- out "Running $file" && . "$file"
-done
+run_hook boot
out "Running rc.local..."; {
[ -r "/etc/init/rc.local" ] && \
diff --git a/rc.lib b/rc.lib
index 919883e..412f98b 100644
--- a/rc.lib
+++ b/rc.lib
@@ -8,3 +8,12 @@ shell() {
error "Dropping to shell, type 'exit' to continue the boot process."
sh -l
}
+
+run_hook() {
+ out "Running '$1' hooks..."
+ for hook in "/etc/init/"*".$1"; do
+ [ -f "$hook" ] || continue
+ out "Running '$hook'..."
+ . "$hook"
+ done
+}
diff --git a/rc.shutdown b/rc.shutdown
index 0b977f2..2266f21 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -5,16 +5,14 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
-out "Waiting for services to stop..."; {
- sv -w196 force-stop /var/service/* >/dev/null 2>&1
- sv exit /var/service/* >/dev/null 2>&1
+run_hook pre.shutdown
+
+command -v sv >/dev/null &&
+ out "Waiting for runit services to stop..."; {
+ sv -w196 force-stop /var/service/* >/dev/null
+ sv exit /var/service/* >/dev/null
}
-out "Running pre shutdown hooks..."
-for file in /etc/init/*.pre.shutdown ; do
- [ -f "$file" ] && \
- out "Running $file" && . "$file"
-done
out "Saving random seed..."; {
dd count=1 bs=512 if=/dev/random of=/var/random.seed