2023-04-19 22:41:05 +02:00
|
|
|
#!/bin/sh
|
2022-09-22 00:01:21 +02:00
|
|
|
|
|
|
|
rl="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
### argv now contains the arguments of the kernel command line that are
|
|
|
|
### not of the form key=value. (The key=value arguments were stored by
|
|
|
|
### s6-linux-init into an envdir, if instructed so via the -s option.)
|
|
|
|
### Normally this argv remains unused because programs that need the
|
|
|
|
### kernel command line usually read it later on from /proc/cmdline -
|
|
|
|
### but just in case, it's available here.
|
|
|
|
|
|
|
|
|
|
|
|
### 1. Early preparation
|
|
|
|
### This is done only once at boot time.
|
|
|
|
### Ideally, this phase should just initialize the service manager.
|
|
|
|
|
2022-09-22 01:10:00 +02:00
|
|
|
mount -t proc none /proc
|
|
|
|
mount -t sysfs none /sys
|
2024-01-05 00:22:02 +01:00
|
|
|
mount -t tmpfs none /tmp
|
2023-03-04 01:39:54 +01:00
|
|
|
# s6-linux-init mounts /dev before this script is called
|
|
|
|
mkdir /dev/pts
|
|
|
|
mount -t devpts none /dev/pts
|
2022-09-22 01:10:00 +02:00
|
|
|
|
2024-02-13 22:41:43 +01:00
|
|
|
mkdir -m 0751 -p /run/services/outputs
|
|
|
|
chgrp system /run/services/outputs
|
|
|
|
|
|
|
|
if test -d /persist; then
|
|
|
|
mkdir -m 0751 -p /persist/services/state
|
|
|
|
(cd /run/services && ln -s ../../persist/services/state .)
|
|
|
|
else
|
|
|
|
mkdir -m 0751 -p /run/services/state
|
|
|
|
fi
|
2023-02-25 23:53:06 +01:00
|
|
|
|
2022-09-22 00:01:21 +02:00
|
|
|
### If your services are managed by s6-rc:
|
|
|
|
### (replace /run/service with your scandir)
|
2024-03-28 22:56:28 +01:00
|
|
|
s6-rc-init -d -c /etc/s6-rc/compiled /run/service
|
2022-09-22 00:01:21 +02:00
|
|
|
|
2024-09-27 16:18:13 +02:00
|
|
|
config.hostname > /proc/sys/kernel/hostname
|
2022-09-22 00:01:21 +02:00
|
|
|
|
|
|
|
### 2. Starting the wanted set of services
|
|
|
|
### This is also called every time you change runlevels with telinit.
|
|
|
|
### (edit the location to suit your installation)
|
|
|
|
### By default, $rl is the string "default", unless you changed it
|
|
|
|
### via the -D option to s6-linux-init-maker.
|
|
|
|
### Numeric arguments from 1 to 5 on the kernel command line will
|
|
|
|
### override the default.
|
|
|
|
|
|
|
|
exec /etc/s6-linux-init/current/scripts/runlevel "$rl"
|
|
|
|
|
|
|
|
|
|
|
|
### If this script is run in a container, then 1. and 2. above do not
|
|
|
|
### apply and you should just call your CMD, if any, or let your
|
|
|
|
### services run.
|
|
|
|
### Something like this:
|
|
|
|
|
|
|
|
# if test -z "$*" ; then return 0 ; fi
|
|
|
|
# $@
|
|
|
|
# echo $? > /run/s6-linux-init-container-results/exitcode
|
|
|
|
# halt
|