Created
April 8, 2021 20:56
-
-
Save Crest/218967a4a86992b6ec2ec75aa92d604e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init_path="/command/s6-init:/sbin/init:/sbin/oinit:/sbin/init.bak:/rescue/init" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/execlineb | |
# In theory we could use the command line arguments e.g. "-s" for single user boot | |
/usr/local/bin/export PATH "/command:/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin" | |
# Replace variables | |
/usr/local/bin/multisubstitute { | |
define FIFO /run/service/default-log/fifo | |
define CTRL /run/service/.s6-svscan/control | |
define SDIR /etc/service | |
define RDIR /run/service | |
define MASK 022 | |
define SIZE 33554432 | |
} | |
cd / | |
umask $MASK | |
# Setup stdin, stdout and stderr | |
redirfd -r 0 /dev/null | |
redirfd -w 1 /dev/console | |
fdmove -c 2 1 | |
# Prepare the system for s6-svscan | |
foreground { echo "\r\n--==[ Stage 1 ]==--\r" } | |
# Pipe a minimal fstab into mount | |
foreground { echo " * Mount /run.\r" } | |
foreground { pipeline { s6-echo "tmpfs /run tmpfs rw,mode=0755,size=${RUN_SIZE} 0 0" } export PATH_FSTAB /dev/stdin mount -a } | |
foreground { s6-echo "* Populate /run ...\r" } | |
foreground { s6-hiercopy /etc/run /run } | |
# Enable the s6-rc service "normal" | |
redirfd -wnb 3 "${FIFO}" | |
background { | |
# Wait for s6-svscan to start the default logger | |
redirfd -w 3 "${FIFO}" | |
fdclose 3 | |
foreground { echo " * Catch all logger is available.\r" } | |
# Initialize s6-rc in /run/service | |
foreground { echo " * Initializing s6-rc.\r" } | |
foreground { s6-rc-init -p default. /run/service } | |
# Inform the user how far along the system is. | |
foreground { echo "\r\n--==[ Stage 2 ]==--\r" } | |
# Redirect s6-rc output to the default log | |
redirfd -w 1 "${FIFO}" | |
redirfd -w 2 "${FIFO}" | |
s6-rc -v 2 change ok | |
} | |
# Open the default log named fifo non-blocking | |
# and toggle to blocking flag back on. This | |
# allows s6-svscan to start with an open logging | |
# pipe without a reader. | |
fdmove -c 2 3 | |
fdmove 1 3 | |
s6-svscan -t 0 /run/service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment