aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrc.boot12
-rw-r--r--rc.lib20
-rwxr-xr-xrc.shutdown9
3 files changed, 28 insertions, 13 deletions
diff --git a/rc.boot b/rc.boot
index 26edfbe..8c9838d 100755
--- a/rc.boot
+++ b/rc.boot
@@ -78,16 +78,8 @@ out "Enabling swap..."; {
swapon -a || shell
}
-out "Seeding random..."; {
- if [ -f /var/random.seed ]; then
- cat /var/random.seed > /dev/urandom
- else
- out "This may hang."
- out "Mash the keyboard to generate entropy..."
-
- dd count=1 bs=512 if=/dev/random of=/var/random.seed
- fi
-}
+# Load random seed
+random load
out "Setting up loopback..."; {
ip link set up dev lo
diff --git a/rc.lib b/rc.lib
index 412f98b..8d65dd9 100644
--- a/rc.lib
+++ b/rc.lib
@@ -17,3 +17,23 @@ run_hook() {
. "$hook"
done
}
+
+random() {
+ seed=/var/random.seed
+ case "$1" in
+ load)
+ out "Seeding random..."
+ [ -f "$seed" ] || {
+ out "Generating entropy, this might take a while..."
+ dd count=1 bs=512 if=/dev/random of="$seed" 2>/dev/null
+ }
+ cat "$seed" > /dev/urandom
+ ;;
+ save)
+ mkdir -p "${seed%/*}"
+ out "Saving random seed..."
+ dd count=1 bs=512 if=/dev/urandom of="$seed" 2>/dev/null
+ ;;
+ esac
+}
+
diff --git a/rc.shutdown b/rc.shutdown
index 2266f21..e2ea347 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -13,11 +13,14 @@ command -v sv >/dev/null &&
sv exit /var/service/* >/dev/null
}
-
-out "Saving random seed..."; {
- dd count=1 bs=512 if=/dev/random of=/var/random.seed
+command -v svctl >/dev/null &&
+ out "Waiting for sysmgr services to stop..."; {
+ svctl kill /var/sysmgr/* 2>/dev/null
}
+# Save random seed
+random save
+
out "Sending TERM signal to all processes..."; {
killall5 -TERM
sleep 1