From 17c03cf8f0a6339d78ad8fb968ef3b999d658034 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 17 Jul 2017 13:31:20 +0000 Subject: Import /etc/rc.[init tini shutdown] examples from lh-bootstrap --- examples/rc.init | 25 ++++++++++++++++++++++++- examples/rc.shutdown | 9 +++++---- examples/rc.tini | 13 +++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/examples/rc.init b/examples/rc.init index e0b2b72..d71fd1a 100755 --- a/examples/rc.init +++ b/examples/rc.init @@ -1,4 +1,27 @@ #!/bin/execlineb -P + +# Make sure the /dev/urandom entropy pool will be set in +# a not-too-distant future. Ideally we'd block on this, +# but it's not critical, so we don't. + +background -d { s6-fillurandompool } + + +# Set the system clock to something sensible, +# to get coherent logs until the initial NTP message + +if { s6-clock @40000000596c000000000000 } + + +# Initialize the service manager + if { s6-rc-init /run/service } -s6-rc -u change ok-all + + +# Run the service manager. +# Call it twice because the first time may spuriously "timeout" +# due to the clock jumping forward. + +if -nt { s6-rc -t 600000 -- change ok-all } +s6-rc -t 600000 -- change ok-all diff --git a/examples/rc.shutdown b/examples/rc.shutdown index 18c898b..04d7357 100755 --- a/examples/rc.shutdown +++ b/examples/rc.shutdown @@ -1,19 +1,20 @@ #!/bin/execlineb -S0 +foreground { s6-echo "Giving dying processes some grace time." } +foreground { s6-sleep 2 } foreground { s6-echo "Syncing disks." } foreground { s6-sync } foreground { s6-echo "Sending all processes the TERM signal." } foreground { s6-nuke -th } -s6-sleep 2 +foreground { s6-sleep 2 } foreground { s6-echo "Sending all processes the KILL signal." } foreground { s6-nuke -k } wait { } -foreground { s6-echo "Syncing disks." } +foreground { s6-echo "Syncing and unmounting disks." } foreground { s6-sync } -foreground { s6-echo "Unmounting disks." } foreground { s6-umount -a } -foreground { s6-mount -o ro,remount /dev/root / } +foreground { s6-mount -ro remount /dev/root / } foreground { s6-echo "\nPerforming "${1}"." } s6-${1} -f diff --git a/examples/rc.tini b/examples/rc.tini index abefb22..02e7ec7 100755 --- a/examples/rc.tini +++ b/examples/rc.tini @@ -1,3 +1,16 @@ #!/bin/execlineb -P + +# Write a message to /var/log/syslogd + +foreground +{ + s6-ipcclient -l0 /dev/log + fdmove 1 7 + s6-echo "/etc/rc.tini: shutdown requested" +} + + +# Shut down all services + s6-rc -da change -- cgit v1.2.3