diff --git a/overlay/etc/s6/crash b/overlay/etc/s6/crash new file mode 100755 index 0000000..d097e76 --- /dev/null +++ b/overlay/etc/s6/crash @@ -0,0 +1,14 @@ +#!/command/execlineb -P + +# This file is run when an unrecoverable error happens +# to s6-svscan. Edit it to suit your needs. + +cd / +redirfd -r 0 /dev/console +redirfd -w 1 /dev/console +fdmove -c 2 1 + +foreground { s6-echo "s6-svscan panicked! Dropping to a root shell.\n" } + +/bin/sh -i + diff --git a/overlay/etc/s6/env/PATH b/overlay/etc/s6/env/PATH new file mode 100644 index 0000000..415f082 --- /dev/null +++ b/overlay/etc/s6/env/PATH @@ -0,0 +1 @@ +/usr/bin diff --git a/overlay/etc/s6/init-stage1 b/overlay/etc/s6/init-stage1 new file mode 100755 index 0000000..5833c73 --- /dev/null +++ b/overlay/etc/s6/init-stage1 @@ -0,0 +1,39 @@ +#!/usr/bin/execlineb -P + +# This file is the first program run at boot time, +# as process 1. +# Edit it to suit your needs. + +# Make sure everything is sane and ignore input +cd / +umask 022 +fdclose 0 + +/etc/s6/crash + +# This should be printed to the console +if { s6-echo "* init stage 1" } + + +# Mount /sys and /proc +if { s6-mount -wt sysfs sys /sysfs } +if { s6-mount -wt proc proc /procfs } + +# Close remaining handles to /dev/console +fdclose 1 fdclose 2 + +# Now no process has any open fd to /dev/console (or to +# anything for that matter). +# We can safely overwrite the minimal /dev with the real one. + +# Reopen stdin/stdout/stderr and make them point to the right places +redirfd -r 0 /dev/null +redirfd -wnb 1 /service/s6-svscan-log/fifo # (black magic: doesn't block) +fdmove -c 2 1 + +# Load the general environment +s6-envdir /etc/s6/env + +# Start stage 2. +s6-svscan -t0 /service + diff --git a/overlay/etc/s6/init-stage3 b/overlay/etc/s6/init-stage3 new file mode 100755 index 0000000..88d7bba --- /dev/null +++ b/overlay/etc/s6/init-stage3 @@ -0,0 +1,47 @@ +#!/command/execlineb -S0 + +# This is the shutdown script, running as process 1. + +# Make sure we have no open handle to anywhere else +# than /dev/console +cd / +fdclose 0 +redirfd -w 1 /dev/console +fdmove -c 2 1 + +foreground { s6-echo "Syncing disks." } +foreground { s6-sync } + + +# Even if s6-svscan properly brought all the services down +# before exec'ing into this script, users might have launched +# background nohup processes, so we have to kill everything. + +foreground { s6-echo "Sending all processes the TERM signal." } +foreground { s6-nuke -th } +foreground { s6-sleep 1 } +foreground { s6-echo "Sending all processes the KILL signal." } +foreground { s6-nuke -k } + +# Here, s6-nuke sends a SIGKILL to every process on the system. +# It kills itself, but not before the SIGKILL has been broadcast. +# The "foreground" process runs as process 1, so it survives, +# and execs into the rest of the script when s6-nuke dies. + +# Reap the huge army of zombies we just created +wait { } + + +foreground { s6-echo "Syncing disks." } +foreground { s6-sync } # yes, it helps. +foreground { s6-echo "Unmounting disks." } + +# Unmount all your filesystems here, turn off swap, +# remount / read-only if needed, etc. +# foreground { s6-umount /mnt/rwfs } + +# Reboot, halt or poweroff the machine, depending on the parameter +# that was given to the script. +foreground { s6-echo "\nPerforming "${1}"." } +s6-${1} + diff --git a/overlay/service/.s6-svscan/crash b/overlay/service/.s6-svscan/crash new file mode 120000 index 0000000..432891e --- /dev/null +++ b/overlay/service/.s6-svscan/crash @@ -0,0 +1 @@ +/etc/s6/crash \ No newline at end of file diff --git a/overlay/service/.s6-svscan/finish b/overlay/service/.s6-svscan/finish new file mode 120000 index 0000000..44c7cf4 --- /dev/null +++ b/overlay/service/.s6-svscan/finish @@ -0,0 +1 @@ +/etc/s6/finish \ No newline at end of file diff --git a/overlay/usr/bin/init b/overlay/usr/bin/init new file mode 120000 index 0000000..770d588 --- /dev/null +++ b/overlay/usr/bin/init @@ -0,0 +1 @@ +/etc/s6/init-stage1 \ No newline at end of file diff --git a/packages b/packages index 983f6da..3ddcb47 100644 --- a/packages +++ b/packages @@ -12,5 +12,3 @@ pacman procps-ng radvd sed -systemd -systemd-sysvcompat