├── .gitignore ├── LICENSE.md ├── README.md ├── env ├── LANG └── LC_COLLATE ├── init ├── run-image └── service │ ├── .s6-svscan │ ├── SIGHUP │ ├── SIGINT │ ├── SIGQUIT │ ├── SIGTERM │ ├── SIGUSR1 │ ├── SIGUSR2 │ ├── crash │ └── finish │ ├── s6-linux-init-early-getty │ └── run │ ├── s6-linux-init-runleveld │ ├── notification-fd │ └── run │ ├── s6-linux-init-shutdownd │ └── run │ └── s6-svscan-log │ ├── notification-fd │ └── run ├── scripts ├── rc.init ├── rc.shutdown └── runlevel ├── shutdown ├── source ├── backlight │ ├── dependencies │ ├── down │ ├── instances │ ├── type │ └── up ├── clock │ ├── down │ ├── type │ └── up ├── crond │ ├── dependencies │ ├── run │ └── type ├── cupsd │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── default │ ├── contents │ └── type ├── devices │ ├── contents │ └── type ├── dhcpcd │ ├── dependencies │ ├── run │ └── type ├── dnsmasq │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── filesystems │ ├── contents │ └── type ├── firewall │ ├── dependencies │ ├── down │ ├── type │ └── up ├── getty │ ├── dependencies │ ├── instances │ ├── run │ └── type ├── hostname │ ├── type │ └── up ├── klogd │ ├── logdir │ ├── run │ └── type ├── loopback │ ├── down │ ├── type │ └── up ├── mount-cgroups │ ├── dependencies │ ├── down │ ├── type │ └── up ├── mount-dev │ ├── down │ ├── type │ └── up ├── mount-fstab │ ├── dependencies │ ├── down │ ├── instances │ ├── type │ └── up ├── mount-swap │ ├── dependencies │ ├── down │ ├── type │ └── up ├── mount-sys │ ├── down │ ├── type │ └── up ├── mount-tmp │ ├── down │ ├── type │ └── up ├── mount-zfs │ ├── dependencies │ ├── down │ ├── type │ └── up ├── networking │ ├── dependencies │ ├── down │ ├── type │ └── up ├── ntpd │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── nullhttpd │ ├── run │ └── type ├── random │ ├── dependencies │ ├── down │ ├── type │ └── up ├── runc │ ├── dependencies │ ├── instances │ ├── logdir │ ├── run │ └── type ├── smartd │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── smtpd │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── ssh-keygen │ ├── dependencies │ ├── type │ └── up ├── sshd │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── sysctl │ ├── type │ └── up ├── syslogd │ ├── logdir │ ├── notification-fd │ ├── run │ └── type ├── tmpfiles │ ├── dependencies │ ├── type │ └── up ├── udev-coldplug │ ├── dependencies │ ├── type │ └── up ├── udevd │ ├── dependencies │ ├── notification-fd │ ├── run │ └── type ├── upsd │ ├── dependencies │ ├── run │ └── type ├── upsdrv │ ├── dependencies │ ├── instances │ ├── run │ └── type ├── upsmon │ ├── dependencies │ ├── logdir │ ├── run │ └── type ├── user-log │ ├── consumer-for │ ├── dependencies │ ├── instances │ ├── notification-fd │ ├── run │ └── type ├── user-services │ ├── dependencies │ ├── instances │ ├── producer-for │ ├── run │ └── type ├── user-session │ ├── dependencies │ ├── down │ ├── instances │ ├── type │ └── up ├── user-setup │ ├── dependencies │ ├── down │ ├── instances │ ├── type │ └── up ├── wireguard │ ├── dependencies │ ├── instances │ ├── type │ └── up ├── wpa_supplicant-wired │ ├── dependencies │ ├── instances │ ├── run │ └── type ├── wpa_supplicant │ ├── dependencies │ ├── instances │ ├── run │ └── type └── zed │ ├── dependencies │ ├── run │ └── type └── update /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | compiled 3 | compiled*/ 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ## BSD Zero Clause License 2 | 3 | Copyright © 2016-2018 Samuel Holland 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 10 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 13 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 | PERFORMANCE OF THIS SOFTWARE. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | This is the set of scripts and service definitions used on all of [my][smaeul] 4 | Linux boxes. You can use this repository as a starting point for your machines, 5 | or you can copy individual service directories as needed. Keep in mind that the 6 | format extensions below are provided by the scripts in this repository, not by 7 | s6-rc, so you will have to "de-sugar" run scripts taken from this repository. 8 | 9 | These scripts and service directories were developed on gentoo-musl, but they 10 | should work on any Linux distribution (possibly with minor modification). 11 | 12 | For examples of user-level service definitions, also managed by similar scripts 13 | and s6-rc, see [https://github.com/smaeul/rc-user][rc-user]. 14 | 15 | ## Dependencies 16 | 1. The [s6][s6]/[s6-linux-init][s6-linux-init]/[s6-rc][s6-rc] software suite 17 | and its dependencies. 18 | 2. Standard POSIX command-line utilities, plus `install` and a `date` with GNU 19 | extensions. These can be provided by coreutils/psmisc/util-linux or busybox. 20 | 21 | ## Installation 22 | 1. Clone this repository to `/etc/rc`. Putting it somewhere else is fine, but 23 | requires modifying the `init` and `update` scripts (as well as the service 24 | dirs in `run-image`) to point to the correct location. 25 | 2. Configure the desired set of services (see below). A supervisor will be run 26 | for all services except those with a `disabled` marker, but only those 27 | services contained in the `default` bundle (and their dependencies) will be 28 | started at boot. Adding the `disabled` marker file will automatically remove 29 | a service from all bundles. 30 | 3. Create required users. The fd holder is run as `nobody`, and all 31 | automatically-generated logger services run under the `log` user (this can 32 | be changed in the `update` script and the `s6-svscan-log` run script). 33 | Some services may require their own individual users; see their respective 34 | run scripts. 35 | 4. Run `/etc/rc/update` to compile the service database. 36 | 5. Add `init=/etc/rc/init` to your kernel command line (replacing any 37 | existing init path). 38 | 6. Reboot. 39 | 40 | ## Configuration 41 | 42 | All of the [s6][s6] and [s6-rc][s6-rc] documentation applies here. In addition, 43 | the `update` script implements a few extensions to the service directory 44 | format. 45 | 46 | ### `disabled` 47 | 48 | Presence of this file causes the service to be entirely excluded from the 49 | compiled database. No supervisor will be created for it at runtime, and it will 50 | be removed from all bundles. 51 | 52 | ### `instances` 53 | 54 | This file contains a list of "instances" (variants) of the service, with one 55 | instance name on each line. If this file is present, the `update` script 56 | creates a copy of the service for each instance, suffixed with the (lightly 57 | escaped) instance name, and with all occurrences of the string `%I` in the 58 | service directory replaced by the instance name. The `update` script also 59 | generates a bundle (named the same as the original service) containing all of 60 | the instantiated services. 61 | 62 | Note that if the `instances` file is present and empty, only an empty bundle is 63 | created. This ensures dependencies are always satisfied, even if no instances 64 | of the service are needed. 65 | 66 | ### `logdir` 67 | 68 | The content of this file (one line) specifies a subdirectory of `/var/log` 69 | where logs for this service are stored. If this file is present, the `update` 70 | script creates a logger service and a pipeline connecting this service to its 71 | logger. 72 | 73 | ## Troubleshooting 74 | 75 | * An early getty is created on tty4 by default. If you still cannot log in, and 76 | you use PAM, ensure that /var is writable. 77 | * Logs for everything that doesn't have a `logdir` file, including `s6-rc` 78 | itself, are in `/run/uncaught-logs`. 79 | 80 | ## Updates 81 | 82 | Simply run `/etc/rc/update` after making changes to the source files. 83 | Occasionally, you may wish to clean out old compiled databases. They are stored 84 | in directories `/etc/rc/compiled.${TIMESTAMP}`. Be sure not to delete the 85 | current (latest) compiled database, as it is required for s6-rc to function. 86 | 87 | If, for some reason, you need to recreate the database on disk without touching 88 | the live database, remove also the `compiled` symlink. Note that this will 89 | prevent using `s6-rc-update` until you reboot. 90 | 91 | [rc-user]: https://github.com/smaeul/rc-user 92 | [s6]: https://skarnet.org/software/s6/ 93 | [s6-linux-init]: https://skarnet.org/software/s6-linux-init/ 94 | [s6-rc]: https://skarnet.org/software/s6-rc/ 95 | [smaeul]: https://github.com/smaeul 96 | -------------------------------------------------------------------------------- /env/LANG: -------------------------------------------------------------------------------- 1 | C.UTF-8 2 | -------------------------------------------------------------------------------- /env/LC_COLLATE: -------------------------------------------------------------------------------- 1 | C 2 | -------------------------------------------------------------------------------- /init: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | foreground { mount -no nodev,noexec,nosuid -t proc proc /proc } 4 | foreground { mount -no mode=0755,nosuid,size=1M -t devtmpfs dev /dev } 5 | foreground { mount -no mode=0755,nodev,nosuid,size=64M -t tmpfs run /run } 6 | if { mkdir -p /run/service/s6-linux-init-shutdownd /run/service/s6-svscan-log } 7 | if { mkfifo -m 0600 /run/service/s6-linux-init-shutdownd/fifo /run/service/s6-svscan-log/fifo } 8 | s6-linux-init -N -c /etc/rc -p /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin 9 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/SIGHUP: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdown -a -r -- now 4 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/SIGINT: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdown -a -r -- now 4 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/SIGQUIT: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdown -a -r -- now 4 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/SIGTERM: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdown -a -r -- now 4 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/SIGUSR1: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdown -a -p -- now 4 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/SIGUSR2: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdown -a -h -- now 4 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/crash: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | redirfd -w 1 /dev/console 4 | fdmove -c 2 1 5 | foreground { s6-linux-init-echo -- "s6-svscan crashed. Rebooting." } 6 | /etc/rc/shutdown -r 7 | -------------------------------------------------------------------------------- /run-image/service/.s6-svscan/finish: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | redirfd -w 1 /dev/console 4 | fdmove -c 2 1 5 | foreground { s6-linux-init-echo -- "s6-svscan exited. Rebooting." } 6 | /etc/rc/shutdown -r 7 | -------------------------------------------------------------------------------- /run-image/service/s6-linux-init-early-getty/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | agetty tty4 4 | -------------------------------------------------------------------------------- /run-image/service/s6-linux-init-runleveld/notification-fd: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /run-image/service/s6-linux-init-runleveld/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | fdmove 1 3 5 | s6-ipcserver -1 -a 0700 -c 1 -- s 6 | s6-sudod -0 -1 -2 -t 30000 -- 7 | "/etc/rc"/scripts/runlevel 8 | -------------------------------------------------------------------------------- /run-image/service/s6-linux-init-shutdownd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-linux-init-shutdownd -c "/etc/rc" -g 2000 4 | -------------------------------------------------------------------------------- /run-image/service/s6-svscan-log/notification-fd: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /run-image/service/s6-svscan-log/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | redirfd -w 2 /dev/console 4 | redirfd -w 1 /dev/null 5 | redirfd -rnb 0 fifo 6 | if { install -d -m 0750 -o log -g log /run/uncaught-logs } 7 | umask 027 8 | s6-setuidgid log 9 | s6-log -bpd3 -- !zstd t /run/uncaught-logs 10 | -------------------------------------------------------------------------------- /scripts/rc.init: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -WS1 2 | 3 | if { s6-rc-init -c /etc/rc/compiled -t 1000 /run/service } 4 | s6-rc -bpu change $@ 5 | -------------------------------------------------------------------------------- /scripts/rc.shutdown: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-rc -abd change 4 | -------------------------------------------------------------------------------- /scripts/runlevel: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -WS1 2 | 3 | s6-rc -pu change $@ 4 | -------------------------------------------------------------------------------- /shutdown: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -S0 2 | 3 | foreground { sync } 4 | foreground { kill -TERM -- -1 } 5 | wait -t 2000 { } 6 | foreground { kill -KILL -- -1 } 7 | wait -r { } 8 | foreground { sync } 9 | foreground { s6-linux-init-umountall } 10 | foreground { sync } 11 | s6-linux-init-hpr -f -r $@ 12 | -------------------------------------------------------------------------------- /source/backlight/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | filesystems 3 | -------------------------------------------------------------------------------- /source/backlight/down: -------------------------------------------------------------------------------- 1 | redirfd -w 1 /var/lib/misc/backlight@%I 2 | cat /sys/class/backlight/%I/brightness 3 | -------------------------------------------------------------------------------- /source/backlight/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/backlight/instances -------------------------------------------------------------------------------- /source/backlight/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/backlight/up: -------------------------------------------------------------------------------- 1 | if -t { test -r /var/lib/misc/backlight@%I } 2 | redirfd -w 1 /sys/class/backlight/%I/brightness 3 | cat /var/lib/misc/backlight@%I 4 | -------------------------------------------------------------------------------- /source/clock/down: -------------------------------------------------------------------------------- 1 | if { mkdir -p /var/lib/misc } 2 | if -t { 3 | if -t { test -r /var/lib/misc/timestamp } 4 | backtick -n then { stat -c %Y /var/lib/misc/timestamp } 5 | backtick -n now { date +%s } 6 | multisubstitute { 7 | importas -u then then 8 | importas -u now now 9 | } 10 | test ${then} -le ${now} 11 | } 12 | touch /var/lib/misc/timestamp 13 | -------------------------------------------------------------------------------- /source/clock/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/clock/up: -------------------------------------------------------------------------------- 1 | if -t { test -r /var/lib/misc/timestamp } 2 | backtick -n then { stat -c %Y /var/lib/misc/timestamp } 3 | backtick -n now { date +%s } 4 | multisubstitute { 5 | importas -u then then 6 | importas -u now now 7 | } 8 | if -t { test ${then} -gt ${now} } 9 | if { printf "Setting system clock: " } 10 | date -s @${then} 11 | -------------------------------------------------------------------------------- /source/crond/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | smtpd 3 | -------------------------------------------------------------------------------- /source/crond/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | bcron-start 4 | -------------------------------------------------------------------------------- /source/crond/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/cupsd/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | -------------------------------------------------------------------------------- /source/cupsd/logdir: -------------------------------------------------------------------------------- 1 | cupsd 2 | -------------------------------------------------------------------------------- /source/cupsd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | cupsd -f 5 | -------------------------------------------------------------------------------- /source/cupsd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/default/contents: -------------------------------------------------------------------------------- 1 | backlight 2 | clock 3 | crond 4 | cupsd 5 | devices 6 | dhcpcd 7 | dnsmasq 8 | filesystems 9 | firewall 10 | getty 11 | hostname 12 | klogd 13 | loopback 14 | networking 15 | ntpd 16 | nullhttpd 17 | random 18 | runc 19 | smartd 20 | smtpd 21 | sshd 22 | sysctl 23 | syslogd 24 | tmpfiles 25 | udevd 26 | upsd 27 | upsmon 28 | user-session 29 | user-setup 30 | wireguard 31 | wpa_supplicant 32 | wpa_supplicant-wired 33 | zed 34 | -------------------------------------------------------------------------------- /source/default/type: -------------------------------------------------------------------------------- 1 | bundle 2 | -------------------------------------------------------------------------------- /source/devices/contents: -------------------------------------------------------------------------------- 1 | mount-dev 2 | udev-coldplug 3 | -------------------------------------------------------------------------------- /source/devices/type: -------------------------------------------------------------------------------- 1 | bundle 2 | -------------------------------------------------------------------------------- /source/dhcpcd/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | networking 3 | random 4 | -------------------------------------------------------------------------------- /source/dhcpcd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | dhcpcd -BM 4 | -------------------------------------------------------------------------------- /source/dhcpcd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/dnsmasq/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | networking 3 | random 4 | -------------------------------------------------------------------------------- /source/dnsmasq/logdir: -------------------------------------------------------------------------------- 1 | dnsmasq 2 | -------------------------------------------------------------------------------- /source/dnsmasq/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | dnsmasq -8 - -g dnsmasq -k -u dnsmasq --pid-file 5 | -------------------------------------------------------------------------------- /source/dnsmasq/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/filesystems/contents: -------------------------------------------------------------------------------- 1 | mount-cgroups 2 | mount-dev 3 | mount-fstab 4 | mount-swap 5 | mount-sys 6 | mount-tmp 7 | mount-zfs 8 | tmpfiles 9 | -------------------------------------------------------------------------------- /source/filesystems/type: -------------------------------------------------------------------------------- 1 | bundle 2 | -------------------------------------------------------------------------------- /source/firewall/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | networking 3 | -------------------------------------------------------------------------------- /source/firewall/down: -------------------------------------------------------------------------------- 1 | if -t { 2 | redirfd -w 1 /var/lib/nftables/rules-save 3 | nft list ruleset 4 | } 5 | foreground { nft flush ruleset } 6 | -------------------------------------------------------------------------------- /source/firewall/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/firewall/up: -------------------------------------------------------------------------------- 1 | if -t { test -r /var/lib/nftables/rules } 2 | nft -f /var/lib/nftables/rules 3 | -------------------------------------------------------------------------------- /source/getty/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | hostname 3 | -------------------------------------------------------------------------------- /source/getty/instances: -------------------------------------------------------------------------------- 1 | tty1 2 | tty2 3 | tty3 4 | -------------------------------------------------------------------------------- /source/getty/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | agetty %I 4 | -------------------------------------------------------------------------------- /source/getty/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/hostname/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/hostname/up: -------------------------------------------------------------------------------- 1 | if -t { test -r /etc/hostname } 2 | hostname -F /etc/hostname 3 | -------------------------------------------------------------------------------- /source/klogd/logdir: -------------------------------------------------------------------------------- 1 | dmesg 2 | -------------------------------------------------------------------------------- /source/klogd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | redirfd -r 0 /proc/kmsg 5 | s6-setuidgid nobody 6 | ucspilogd 7 | -------------------------------------------------------------------------------- /source/klogd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/loopback/down: -------------------------------------------------------------------------------- 1 | ip link set lo down 2 | -------------------------------------------------------------------------------- /source/loopback/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/loopback/up: -------------------------------------------------------------------------------- 1 | ip link set lo up 2 | -------------------------------------------------------------------------------- /source/mount-cgroups/dependencies: -------------------------------------------------------------------------------- 1 | mount-sys 2 | -------------------------------------------------------------------------------- /source/mount-cgroups/down: -------------------------------------------------------------------------------- 1 | if -t { mountpoint -q /sys/fs/cgroup } 2 | umount -l /sys/fs/cgroup 3 | -------------------------------------------------------------------------------- /source/mount-cgroups/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-cgroups/up: -------------------------------------------------------------------------------- 1 | if -t { test -e /proc/cgroups } 2 | if { 3 | if -nt { mountpoint -q /sys/fs/cgroup } 4 | mount -o mode=0755,noatime,nodev,noexec,nosuid,size=1M -t tmpfs cgroup /sys/fs/cgroup 5 | } 6 | pipeline { sed -n "1d;s/^\\([[:alpha:]]\\{1,\\}\\)\\t.*\\t1$/\\1/p" /proc/cgroups } 7 | forstdin -p controller 8 | importas -u controller controller 9 | if -nt { mountpoint -q /sys/fs/cgroup/${controller} } 10 | if { mkdir -p /sys/fs/cgroup/${controller} } 11 | mount -o ${controller} -t cgroup cgroup /sys/fs/cgroup/${controller} 12 | -------------------------------------------------------------------------------- /source/mount-dev/down: -------------------------------------------------------------------------------- 1 | foreground { 2 | if -t { mountpoint -q /dev/hugepages } 3 | umount -l /dev/hugepages 4 | } 5 | foreground { 6 | if -t { mountpoint -q /dev/mqueue } 7 | umount -l /dev/mqueue 8 | } 9 | foreground { 10 | if -t { mountpoint -q /dev/pts } 11 | umount -l /dev/pts 12 | } 13 | foreground { 14 | if -t { mountpoint -q /dev/shm } 15 | umount -l /dev/shm 16 | } 17 | -------------------------------------------------------------------------------- /source/mount-dev/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-dev/up: -------------------------------------------------------------------------------- 1 | if { ln -fns /proc/self/fd /dev/fd } 2 | if { ln -fns /proc/self/fd/0 /dev/stdin } 3 | if { ln -fns /proc/self/fd/1 /dev/stdout } 4 | if { ln -fns /proc/self/fd/2 /dev/stderr } 5 | foreground { 6 | if -t { grep -Fq hugetlbfs /proc/filesystems } 7 | if -nt { mountpoint -q /dev/hugepages } 8 | if { mkdir -p /dev/hugepages } 9 | mount -o noatime,nodev,noexec,nosuid -t hugetlbfs hugepages /dev/hugepages 10 | } 11 | foreground { 12 | if -t { grep -Fq mqueue /proc/filesystems } 13 | if -nt { mountpoint -q /dev/mqueue } 14 | if { mkdir -p /dev/mqueue } 15 | mount -o noatime,nodev,noexec,nosuid -t mqueue mqueue /dev/mqueue 16 | } 17 | foreground { 18 | if -t { grep -Fq devpts /proc/filesystems } 19 | if -nt { mountpoint -q /dev/pts } 20 | if { mkdir -p /dev/pts } 21 | if { mount -o noexec,nosuid,ptmxmode=0666 -t devpts devpts /dev/pts } 22 | ln -fns pts/ptmx /dev/ptmx 23 | } 24 | foreground { 25 | if -nt { mountpoint -q /dev/shm } 26 | if { mkdir -p /dev/shm } 27 | mount -o noatime,nodev,noexec,nosuid -t tmpfs shm /dev/shm 28 | } 29 | -------------------------------------------------------------------------------- /source/mount-fstab/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | -------------------------------------------------------------------------------- /source/mount-fstab/down: -------------------------------------------------------------------------------- 1 | foreground { umount -r %I } 2 | -------------------------------------------------------------------------------- /source/mount-fstab/instances: -------------------------------------------------------------------------------- 1 | / 2 | /boot 3 | /var 4 | -------------------------------------------------------------------------------- /source/mount-fstab/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-fstab/up: -------------------------------------------------------------------------------- 1 | ifte { mount -o remount %I } { mount %I } 2 | mountpoint -q %I 3 | -------------------------------------------------------------------------------- /source/mount-swap/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | -------------------------------------------------------------------------------- /source/mount-swap/down: -------------------------------------------------------------------------------- 1 | swapoff -a 2 | -------------------------------------------------------------------------------- /source/mount-swap/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-swap/up: -------------------------------------------------------------------------------- 1 | swapon -a 2 | -------------------------------------------------------------------------------- /source/mount-sys/down: -------------------------------------------------------------------------------- 1 | if -t { mountpoint -q /sys } 2 | umount -l /sys 3 | -------------------------------------------------------------------------------- /source/mount-sys/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-sys/up: -------------------------------------------------------------------------------- 1 | if { 2 | if -nt { mountpoint -q /sys } 3 | mount -o noatime,nodev,noexec,nosuid -t sysfs sys /sys 4 | } 5 | foreground { 6 | if -t { grep -Fq efivarfs /proc/filesystems } 7 | if -nt { mountpoint -q /sys/firmware/efi/efivars } 8 | mount -o noatime,nodev,noexec,nosuid,ro -t efivarfs efivars /sys/firmware/efi/efivars 9 | } 10 | foreground { 11 | if -t { grep -Fq fusectl /proc/filesystems } 12 | if -nt { mountpoint -q /sys/fs/fuse/connections } 13 | mount -o noatime,nodev,noexec,nosuid -t fusectl fusectl /sys/fs/fuse/connections 14 | } 15 | foreground { 16 | if -t { grep -Fq configfs /proc/filesystems } 17 | if -nt { mountpoint -q /sys/kernel/config } 18 | mount -o noatime,nodev,noexec,nosuid -t configfs configfs /sys/kernel/config 19 | } 20 | foreground { 21 | if -t { grep -Fq debugfs /proc/filesystems } 22 | if -nt { mountpoint -q /sys/kernel/debug } 23 | mount -o noatime,nodev,noexec,nosuid -t debugfs debugfs /sys/kernel/debug 24 | } 25 | foreground { 26 | if -t { grep -Fq tracefs /proc/filesystems } 27 | if -nt { mountpoint -q /sys/kernel/debug/tracing } 28 | mount -o noatime,nodev,noexec,nosuid -t tracefs tracefs /sys/kernel/debug/tracing 29 | } 30 | foreground { 31 | if -t { grep -Fq securityfs /proc/filesystems } 32 | if -nt { mountpoint -q /sys/kernel/security } 33 | mount -o noatime,nodev,noexec,nosuid -t securityfs securityfs /sys/kernel/security 34 | } 35 | -------------------------------------------------------------------------------- /source/mount-tmp/down: -------------------------------------------------------------------------------- 1 | if -t { mountpoint -q /tmp } 2 | umount -l /tmp 3 | -------------------------------------------------------------------------------- /source/mount-tmp/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-tmp/up: -------------------------------------------------------------------------------- 1 | mount -o noatime,nodev,nosuid -t tmpfs tmp /tmp 2 | -------------------------------------------------------------------------------- /source/mount-zfs/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | -------------------------------------------------------------------------------- /source/mount-zfs/down: -------------------------------------------------------------------------------- 1 | foreground { 2 | redirfd -w 2 /dev/null 3 | zfs umount -a 4 | } 5 | -------------------------------------------------------------------------------- /source/mount-zfs/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/mount-zfs/up: -------------------------------------------------------------------------------- 1 | zfs mount -a 2 | -------------------------------------------------------------------------------- /source/networking/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | hostname 3 | loopback 4 | sysctl 5 | -------------------------------------------------------------------------------- /source/networking/down: -------------------------------------------------------------------------------- 1 | if { 2 | cd /etc/net/routes 3 | s6-envdir -f . 4 | elglob -0s list * 5 | forx iface { ${list} } 6 | importas -u iface iface 7 | importas -su -d"\n" ${iface} ${iface} 8 | forx route { ${${iface}} } 9 | importas -su route route 10 | ip route delete dev ${iface} ${route} 11 | } 12 | if { 13 | cd /etc/net/addresses 14 | s6-envdir -f . 15 | elglob -0s list * 16 | forx iface { ${list} } 17 | importas -u iface iface 18 | importas -su -d"\n" ${iface} ${iface} 19 | forx addr { ${${iface}} } 20 | importas -su addr addr 21 | ip address delete dev ${iface} ${addr} 22 | } 23 | if { 24 | cd /etc/net/interfaces 25 | s6-envdir -f . 26 | elglob -0s list * 27 | forx iface { ${list} } 28 | importas -u iface iface 29 | if -t { grep -Fq ${iface} /proc/net/dev } 30 | ip link set ${iface} down 31 | } 32 | -------------------------------------------------------------------------------- /source/networking/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/networking/up: -------------------------------------------------------------------------------- 1 | if { 2 | cd /etc/net/interfaces 3 | s6-envdir -f . 4 | elglob -0s list * 5 | forx iface { ${list} } 6 | importas -u iface iface 7 | if -nt { grep -Fq ${iface} /proc/net/dev } 8 | importas -su ${iface} ${iface} 9 | ip link add ${iface} ${${iface}} 10 | } 11 | if { 12 | cd /etc/net/links 13 | s6-envdir -f . 14 | elglob -0s list * 15 | forx iface { ${list} } 16 | importas -u iface iface 17 | importas -su -d"\n" ${iface} ${iface} 18 | forx link { ${${iface}} } 19 | importas -su link link 20 | ip link set ${iface} ${link} 21 | } 22 | if { 23 | cd /etc/net/addresses 24 | s6-envdir -f . 25 | elglob -0s list * 26 | forx iface { ${list} } 27 | importas -u iface iface 28 | importas -su -d"\n" ${iface} ${iface} 29 | forx addr { ${${iface}} } 30 | importas -su addr addr 31 | ip address add dev ${iface} ${addr} 32 | } 33 | if { 34 | cd /etc/net/routes 35 | s6-envdir -f . 36 | elglob -0s list * 37 | forx iface { ${list} } 38 | importas -u iface iface 39 | importas -su -d"\n" ${iface} ${iface} 40 | forx route { ${${iface}} } 41 | importas -su route route 42 | ip route replace dev ${iface} ${route} 43 | } 44 | -------------------------------------------------------------------------------- /source/ntpd/dependencies: -------------------------------------------------------------------------------- 1 | clock 2 | -------------------------------------------------------------------------------- /source/ntpd/logdir: -------------------------------------------------------------------------------- 1 | ntpd 2 | -------------------------------------------------------------------------------- /source/ntpd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | s6-envdir -I env 5 | multisubstitute { 6 | importas -u frequency frequency 7 | importas -u -D 2.pool.ntp.org server server 8 | } 9 | ntpclient -f${frequency} -h${server} -i300 -l -s 10 | -------------------------------------------------------------------------------- /source/ntpd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/nullhttpd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | nullhttpd 4 | -------------------------------------------------------------------------------- /source/nullhttpd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/random/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | -------------------------------------------------------------------------------- /source/random/down: -------------------------------------------------------------------------------- 1 | if { mkdir -p /var/lib/misc } 2 | umask 077 3 | redirfd -w 2 /dev/null 4 | dd bs=32 count=256 if=/dev/urandom of=/var/lib/misc/random-seed 5 | -------------------------------------------------------------------------------- /source/random/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/random/up: -------------------------------------------------------------------------------- 1 | if -t { test -r /var/lib/misc/random-seed } 2 | redirfd -w 1 /dev/urandom 3 | cat /var/lib/misc/random-seed 4 | -------------------------------------------------------------------------------- /source/runc/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | networking 3 | random 4 | -------------------------------------------------------------------------------- /source/runc/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/runc/instances -------------------------------------------------------------------------------- /source/runc/logdir: -------------------------------------------------------------------------------- 1 | runc/%I 2 | -------------------------------------------------------------------------------- /source/runc/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | cd /srv/%I 5 | runc run --no-new-keyring --no-subreaper %I 6 | -------------------------------------------------------------------------------- /source/runc/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/smartd/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | smtpd 3 | -------------------------------------------------------------------------------- /source/smartd/logdir: -------------------------------------------------------------------------------- 1 | smartd 2 | -------------------------------------------------------------------------------- /source/smartd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | smartd -n 5 | -------------------------------------------------------------------------------- /source/smartd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/smtpd/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | random 3 | -------------------------------------------------------------------------------- /source/smtpd/logdir: -------------------------------------------------------------------------------- 1 | smtpd 2 | -------------------------------------------------------------------------------- /source/smtpd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | s6-setuidgid nullmail 5 | nullmailer-send 6 | -------------------------------------------------------------------------------- /source/smtpd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/ssh-keygen/dependencies: -------------------------------------------------------------------------------- 1 | random 2 | -------------------------------------------------------------------------------- /source/ssh-keygen/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/ssh-keygen/up: -------------------------------------------------------------------------------- 1 | foreground { ssh-keygen -A } 2 | -------------------------------------------------------------------------------- /source/sshd/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | random 3 | ssh-keygen 4 | -------------------------------------------------------------------------------- /source/sshd/logdir: -------------------------------------------------------------------------------- 1 | sshd 2 | -------------------------------------------------------------------------------- /source/sshd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | /usr/sbin/sshd -De 5 | -------------------------------------------------------------------------------- /source/sshd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/sysctl/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/sysctl/up: -------------------------------------------------------------------------------- 1 | foreground { 2 | redirfd -w 1 /proc/sys/kernel/ctrl-alt-del 3 | printf 0 4 | } 5 | sysctl -eq --system 6 | -------------------------------------------------------------------------------- /source/syslogd/logdir: -------------------------------------------------------------------------------- 1 | syslog 2 | -------------------------------------------------------------------------------- /source/syslogd/notification-fd: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /source/syslogd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-envuidgid nobody 4 | fdmove 2 1 5 | fdmove 1 3 6 | s6-ipcserver -1U /dev/log 7 | fdmove -c 1 2 8 | ucspilogd IPCREMOTEEUID IPCREMOTEEGID 9 | -------------------------------------------------------------------------------- /source/syslogd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/tmpfiles/dependencies: -------------------------------------------------------------------------------- 1 | mount-tmp 2 | -------------------------------------------------------------------------------- /source/tmpfiles/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/tmpfiles/up: -------------------------------------------------------------------------------- 1 | if { mkdir -p /run/lock } 2 | if { touch /run/utmp } 3 | if { install -d -m 1733 /tmp/.X11-unix } 4 | -------------------------------------------------------------------------------- /source/udev-coldplug/dependencies: -------------------------------------------------------------------------------- 1 | udevd 2 | -------------------------------------------------------------------------------- /source/udev-coldplug/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/udev-coldplug/up: -------------------------------------------------------------------------------- 1 | if { udevadm trigger --action=add --attr-match=dev } 2 | if { udevadm trigger --action=add --type=subsystems } 3 | if { udevadm trigger --action=add --type=devices } 4 | udevadm settle 5 | -------------------------------------------------------------------------------- /source/udevd/dependencies: -------------------------------------------------------------------------------- 1 | mount-dev 2 | mount-sys 3 | -------------------------------------------------------------------------------- /source/udevd/notification-fd: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /source/udevd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | background -d { 4 | fdmove 1 3 5 | loopwhilex -x 0 6 | if { sleep 1 } 7 | if { udevadm control --start-exec-queue } 8 | echo 9 | } 10 | unexport ! 11 | fdclose 3 12 | udevd 13 | -------------------------------------------------------------------------------- /source/udevd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/upsd/dependencies: -------------------------------------------------------------------------------- 1 | loopback 2 | upsdrv 3 | -------------------------------------------------------------------------------- /source/upsd/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | if { install -d -g nut -m 0700 -o nut /run/nut } 4 | s6-setuidgid nut 5 | export NUT_STATEPATH /run/nut 6 | redirfd -w 2 /dev/null 7 | upsd -D 8 | -------------------------------------------------------------------------------- /source/upsd/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/upsdrv/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | -------------------------------------------------------------------------------- /source/upsdrv/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/upsdrv/instances -------------------------------------------------------------------------------- /source/upsdrv/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | if { install -d -g nut -m 0700 -o nut /run/nut } 4 | s6-setuidgid nut 5 | export NUT_STATEPATH /run/nut 6 | redirfd -w 2 /dev/null 7 | /lib/nut/usbhid-ups -D -a %I 8 | -------------------------------------------------------------------------------- /source/upsdrv/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/upsmon/dependencies: -------------------------------------------------------------------------------- 1 | smtpd 2 | -------------------------------------------------------------------------------- /source/upsmon/logdir: -------------------------------------------------------------------------------- 1 | upsmon 2 | -------------------------------------------------------------------------------- /source/upsmon/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | fdmove -c 2 1 4 | s6-setuidgid nut 5 | upsmon -D -p 6 | -------------------------------------------------------------------------------- /source/upsmon/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/user-log/consumer-for: -------------------------------------------------------------------------------- 1 | user-services@%I 2 | -------------------------------------------------------------------------------- /source/user-log/dependencies: -------------------------------------------------------------------------------- 1 | user-setup@%I 2 | -------------------------------------------------------------------------------- /source/user-log/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/user-log/instances -------------------------------------------------------------------------------- /source/user-log/notification-fd: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /source/user-log/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | if { install -d -m 0700 -o %I -g %I /run/user/%I/log } 4 | umask 077 5 | s6-setuidgid %I 6 | s6-log -d3 -- !zstd t /run/user/%I/log 7 | -------------------------------------------------------------------------------- /source/user-log/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/user-services/dependencies: -------------------------------------------------------------------------------- 1 | user-setup@%I 2 | -------------------------------------------------------------------------------- /source/user-services/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/user-services/instances -------------------------------------------------------------------------------- /source/user-services/producer-for: -------------------------------------------------------------------------------- 1 | user-log@%I 2 | -------------------------------------------------------------------------------- /source/user-services/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | s6-setuidgid %I 4 | cd /run/user/%I/service 5 | emptyenv -p 6 | s6-envdir /run/user/%I/env 7 | fdmove -c 2 1 8 | subreaper 9 | s6-svscan -S 10 | -------------------------------------------------------------------------------- /source/user-services/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/user-session/dependencies: -------------------------------------------------------------------------------- 1 | user-services@%I 2 | -------------------------------------------------------------------------------- /source/user-session/down: -------------------------------------------------------------------------------- 1 | s6-setuidgid %I 2 | foreground { s6-rc -l /run/user/%I/rc -ad change } 3 | -------------------------------------------------------------------------------- /source/user-session/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/user-session/instances -------------------------------------------------------------------------------- /source/user-session/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/user-session/up: -------------------------------------------------------------------------------- 1 | s6-setuidgid %I 2 | foreground { 3 | umask 077 4 | redirfd -w 2 /dev/null 5 | mkfifo /run/user/%I/service/.s6-svscan/control 6 | } 7 | redirfd -w 3 /run/user/%I/service/.s6-svscan/control 8 | fdclose 3 9 | if { 10 | if -nt { test -d /run/user/%I/rc } 11 | backtick -n HOME { homeof %I } 12 | importas HOME HOME 13 | s6-rc-init -c ${HOME}/.config/rc/compiled -l /run/user/%I/rc /run/user/%I/service 14 | } 15 | s6-rc -l /run/user/%I/rc change default 16 | -------------------------------------------------------------------------------- /source/user-setup/dependencies: -------------------------------------------------------------------------------- 1 | filesystems 2 | -------------------------------------------------------------------------------- /source/user-setup/down: -------------------------------------------------------------------------------- 1 | if -t { mountpoint -q /run/user/%I } 2 | if { umount -l /run/user/%I } 3 | rmdir /run/user/%I 4 | -------------------------------------------------------------------------------- /source/user-setup/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/user-setup/instances -------------------------------------------------------------------------------- /source/user-setup/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/user-setup/up: -------------------------------------------------------------------------------- 1 | if { 2 | if -nt { mountpoint -q /run/user/%I } 3 | if { mkdir -p /run/user/%I } 4 | mount -o noatime,nodev,nosuid,gid=%I,mode=0700,size=64M,uid=%I -t tmpfs user /run/user/%I 5 | } 6 | s6-setuidgid %I 7 | if { mkdir -p /run/user/%I/env } 8 | if { 9 | foreground { 10 | backtick -n HOME { homeof %I } 11 | importas HOME HOME 12 | redirfd -w 1 /run/user/%I/env/HOME 13 | printf %s ${HOME} 14 | } 15 | foreground { 16 | redirfd -w 1 /run/user/%I/env/LOGNAME 17 | printf %s %I 18 | } 19 | foreground { 20 | importas PATH PATH 21 | redirfd -w 1 /run/user/%I/env/PATH 22 | printf %s ${PATH} 23 | } 24 | foreground { 25 | backtick -D /bin/sh -n SHELL { 26 | pipeline { getent passwd %I } 27 | cut -d: -f7 28 | } 29 | importas SHELL SHELL 30 | redirfd -w 1 /run/user/%I/env/SHELL 31 | printf %s ${SHELL} 32 | } 33 | foreground { 34 | redirfd -w 1 /run/user/%I/env/XDG_RUNTIME_DIR 35 | printf %s /run/user/%I 36 | } 37 | } 38 | backtick -n HOME { homeof %I } 39 | importas HOME HOME 40 | rsync -a ${HOME}/.config/rc/image/ /run/user/%I/service/ 41 | -------------------------------------------------------------------------------- /source/wireguard/dependencies: -------------------------------------------------------------------------------- 1 | networking 2 | random 3 | -------------------------------------------------------------------------------- /source/wireguard/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/wireguard/instances -------------------------------------------------------------------------------- /source/wireguard/type: -------------------------------------------------------------------------------- 1 | oneshot 2 | -------------------------------------------------------------------------------- /source/wireguard/up: -------------------------------------------------------------------------------- 1 | wg setconf %I /etc/wireguard/%I.conf 2 | -------------------------------------------------------------------------------- /source/wpa_supplicant-wired/dependencies: -------------------------------------------------------------------------------- 1 | networking 2 | -------------------------------------------------------------------------------- /source/wpa_supplicant-wired/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/wpa_supplicant-wired/instances -------------------------------------------------------------------------------- /source/wpa_supplicant-wired/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | wpa_supplicant -Dwired -i%I -c/etc/wpa_supplicant/wpa_supplicant-%I.conf 4 | -------------------------------------------------------------------------------- /source/wpa_supplicant-wired/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/wpa_supplicant/dependencies: -------------------------------------------------------------------------------- 1 | networking 2 | -------------------------------------------------------------------------------- /source/wpa_supplicant/instances: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smaeul/rc/113e962383972a8ba2831d789069e075207258a6/source/wpa_supplicant/instances -------------------------------------------------------------------------------- /source/wpa_supplicant/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | wpa_supplicant -i%I -c/etc/wpa_supplicant/wpa_supplicant-%I.conf 4 | -------------------------------------------------------------------------------- /source/wpa_supplicant/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /source/zed/dependencies: -------------------------------------------------------------------------------- 1 | devices 2 | syslogd 3 | -------------------------------------------------------------------------------- /source/zed/run: -------------------------------------------------------------------------------- 1 | #!/bin/execlineb -P 2 | 3 | zed -F -p /run/zed.pid -s /run/zed.state 4 | -------------------------------------------------------------------------------- /source/zed/type: -------------------------------------------------------------------------------- 1 | longrun 2 | -------------------------------------------------------------------------------- /update: -------------------------------------------------------------------------------- 1 | #!/bin/sh -eu 2 | # 3 | # s6-rc preprocessor and updater frontend 4 | # Copyright © 2016 Samuel Holland 5 | # See LICENSE in the project directory for license terms. 6 | # vim: expandtab:sts=2:sw=2:ts=8:tw=110 7 | # 8 | 9 | base=/etc/rc 10 | date=$(TZ=UTC0 date +%Y%m%dT%H%M%SZ) 11 | tmpdir=$(mktemp -d) 12 | trap 'rm -rf "$tmpdir"' HUP INT QUIT TERM 13 | 14 | for svcdir in "$base"/source/* ; do 15 | if test -r "$svcdir"/disabled ; then 16 | continue 17 | elif test -r "$svcdir"/contents ; then 18 | svcname=${svcdir##*/} 19 | outdir=${tmpdir}/${svcname} 20 | 21 | mkdir "$outdir" 22 | printf 'bundle\n' > "$outdir"/type 23 | 24 | while read -r member ; do 25 | if ! test -r "${base}/source/${member}"/disabled ; then 26 | printf '%s\n' "$member" >> "${outdir}/contents" 27 | fi 28 | done < "$svcdir"/contents 29 | elif test -r "$svcdir"/instances ; then 30 | svcname=${svcdir##*/} 31 | outdir=${tmpdir}/${svcname} 32 | 33 | mkdir "$outdir" 34 | printf 'bundle\n' > "$outdir"/type 35 | sed -e "s/^/${svcname}@/" -e "s@/@-@g" "$svcdir"/instances > "$outdir"/contents 36 | 37 | while read -r instance ; do 38 | outdir=${tmpdir}/${svcname}@$(echo "${instance}" | tr / -) 39 | 40 | cp -pR "$svcdir" "$outdir" 41 | find "$outdir" -type f -exec sed -i "s@%I@${instance}@g" {} + 42 | done < "$svcdir"/instances 43 | else 44 | cp -pR "$svcdir" "$tmpdir" 45 | fi 46 | done 47 | 48 | for svcdir in "$tmpdir"/* ; do 49 | if test -r "$svcdir"/logdir ; then 50 | svcname=${svcdir##*/} 51 | logname="${svcname}-log" 52 | outdir=${tmpdir}/${logname} 53 | logdir=/var/log/$(cat "$svcdir"/logdir) 54 | 55 | mkdir "$outdir" 56 | printf '%s\n' "$logname" > "${svcdir}/producer-for" 57 | printf '%s\n' "$svcname" > "${outdir}/consumer-for" 58 | printf 'filesystems\n' > "$outdir"/dependencies 59 | printf '3\n' > "$outdir"/notification-fd 60 | cat > "$outdir"/run << EOF 61 | #!/bin/execlineb -P 62 | if { install -d -m 0750 -o log -g log ${logdir} } 63 | umask 027 64 | s6-setuidgid log 65 | s6-log -d3 -- !zstd t ${logdir} 66 | EOF 67 | chmod +x "$outdir"/run 68 | printf 'longrun\n' > "$outdir"/type 69 | fi 70 | done 71 | 72 | if s6-rc-compile -h nobody "${base}/compiled.${date}" "$tmpdir"; then 73 | if test -d "${base}/compiled" ; then 74 | s6-rc-update "${base}/compiled.${date}" 75 | fi 76 | rm -rf "${base}/compiled" 77 | ln -fns "compiled.${date}" "${base}/compiled" 78 | fi 79 | 80 | rm -rf "$tmpdir" 81 | --------------------------------------------------------------------------------