system

the Chamesle handbook, init, live ISO and install helpers
git clone https://github.com/tortr-rs/system
Log | Files | Refs | README | LICENSE

commit 24f47ba7852bfa753caee5ab939e00ffd8841f10
parent 5dace9f0d0c26088d81d9ae22ca8c9b69d45aacc
Author: torter <koubbamohamedrayan@gmail.com>
Date:   Sat, 21 Nov 2026 23:06:24 +0000

dinit instead of winchester: services in /etc/dinit.d, dinitctl enable, init.conf moved over on upgrade; handbook 6.1 to 6.3

Diffstat:
Afiles/etc/dinit.d/NetworkManager | 4++++
Afiles/etc/dinit.d/boot | 4++++
Afiles/etc/dinit.d/dbus | 4++++
Afiles/etc/dinit.d/dhcpcd | 4++++
Afiles/etc/dinit.d/elogind | 4++++
Afiles/etc/dinit.d/gdm | 5+++++
Afiles/etc/dinit.d/iwd | 4++++
Afiles/etc/dinit.d/recovery | 5+++++
Afiles/etc/dinit.d/rootfs | 4++++
Afiles/etc/dinit.d/setup | 4++++
Afiles/etc/dinit.d/single | 6++++++
Afiles/etc/dinit.d/system | 4++++
Afiles/etc/dinit.d/tty1 | 6++++++
Afiles/etc/dinit.d/tty2 | 6++++++
Afiles/etc/dinit.d/tty3 | 6++++++
Afiles/etc/dinit.d/tty4 | 6++++++
Afiles/etc/dinit.d/tty5 | 6++++++
Afiles/etc/dinit.d/tty6 | 6++++++
Afiles/etc/dinit.d/ttyS0 | 6++++++
Afiles/etc/dinit.d/udev-trigger | 5+++++
Afiles/etc/dinit.d/udevd | 4++++
Afiles/etc/dinit.d/wpa_supplicant | 4++++
Dfiles/etc/init.conf | 13-------------
Dfiles/etc/init.sh | 20--------------------
Dfiles/etc/rc | 30------------------------------
Dfiles/etc/rc.d/NetworkManager | 5-----
Dfiles/etc/rc.d/dbus | 11-----------
Dfiles/etc/rc.d/iwd | 5-----
Dfiles/etc/rc.d/modules | 10----------
Dfiles/etc/rc.d/network | 5-----
Dfiles/etc/rc.d/udev | 11-----------
Dfiles/etc/rc.d/wpa_supplicant | 5-----
Dfiles/etc/rc.shutdown | 8--------
Dfiles/etc/rc.subr | 37-------------------------------------
Mfiles/sbin/halt | 2+-
Mfiles/sbin/init | 57++++++---------------------------------------------------
Mfiles/sbin/poweroff | 2+-
Mfiles/sbin/reboot | 2+-
Mfiles/sbin/service | 27+++++----------------------
Mfiles/sbin/shutdown | 8++++----
Afiles/usr/lib/chamesle/dbus | 7+++++++
Afiles/usr/lib/chamesle/dhcpcd | 3+++
Afiles/usr/lib/chamesle/getty | 10++++++++++
Afiles/usr/lib/chamesle/rescue | 5+++++
Afiles/usr/lib/chamesle/rootfs | 27+++++++++++++++++++++++++++
Afiles/usr/lib/chamesle/setup | 12++++++++++++
Afiles/usr/lib/modules-load.d/chamesle.conf | 15+++++++++++++++
Mhandbook/handbook.md | 160+++++++++++++++++++++++++++++++++++--------------------------------------------
Aiso/profile/overlay/etc/dinit.d/boot.d/dbus | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/dhcpcd | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/iwd | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/tty1 | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/tty2 | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/tty3 | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/tty4 | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/tty5 | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/tty6 | 2++
Aiso/profile/overlay/etc/dinit.d/boot.d/ttyS0 | 2++
Aiso/profile/overlay/etc/dinit.d/tty1 | 6++++++
Aiso/profile/overlay/etc/dinit.d/tty2 | 6++++++
Aiso/profile/overlay/etc/dinit.d/tty3 | 6++++++
Aiso/profile/overlay/etc/dinit.d/tty4 | 6++++++
Aiso/profile/overlay/etc/dinit.d/tty5 | 6++++++
Aiso/profile/overlay/etc/dinit.d/tty6 | 6++++++
Aiso/profile/overlay/etc/dinit.d/ttyS0 | 6++++++
Aiso/profile/overlay/etc/hostname | 1+
Diso/profile/overlay/etc/init.conf | 7-------
Mpkg/chamesle-base/post-install | 1+
Apkg/chamesle-base/pre-upgrade | 13+++++++++++++
Mtools/chamesle-bootstrap | 4+++-
Mtools/mkpkgs | 4++--
71 files changed, 356 insertions(+), 340 deletions(-)

diff --git a/files/etc/dinit.d/NetworkManager b/files/etc/dinit.d/NetworkManager @@ -0,0 +1,4 @@ +type = process +command = /usr/sbin/NetworkManager -n +depends-on = dbus +smooth-recovery = true diff --git a/files/etc/dinit.d/boot b/files/etc/dinit.d/boot @@ -0,0 +1,4 @@ +# what dinit starts: the system, then every service enabled with dinitctl enable +type = internal +depends-on = system +waits-for.d = /etc/dinit.d/boot.d diff --git a/files/etc/dinit.d/dbus b/files/etc/dinit.d/dbus @@ -0,0 +1,4 @@ +type = process +command = /usr/lib/chamesle/dbus +depends-on = system +smooth-recovery = true diff --git a/files/etc/dinit.d/dhcpcd b/files/etc/dinit.d/dhcpcd @@ -0,0 +1,4 @@ +type = process +command = /usr/lib/chamesle/dhcpcd +depends-on = system +smooth-recovery = true diff --git a/files/etc/dinit.d/elogind b/files/etc/dinit.d/elogind @@ -0,0 +1,4 @@ +type = process +command = /usr/libexec/elogind/elogind +depends-on = dbus +smooth-recovery = true diff --git a/files/etc/dinit.d/gdm b/files/etc/dinit.d/gdm @@ -0,0 +1,5 @@ +type = process +command = /usr/sbin/gdm +depends-on = elogind +waits-for = NetworkManager +restart = true diff --git a/files/etc/dinit.d/iwd b/files/etc/dinit.d/iwd @@ -0,0 +1,4 @@ +type = process +command = /usr/libexec/iwd +depends-on = dbus +smooth-recovery = true diff --git a/files/etc/dinit.d/recovery b/files/etc/dinit.d/recovery @@ -0,0 +1,5 @@ +# what dinit runs when boot fails +type = process +command = /usr/lib/chamesle/rescue +options = runs-on-console +restart = false diff --git a/files/etc/dinit.d/rootfs b/files/etc/dinit.d/rootfs @@ -0,0 +1,4 @@ +type = scripted +command = /usr/lib/chamesle/rootfs +options = starts-on-console +restart = false diff --git a/files/etc/dinit.d/setup b/files/etc/dinit.d/setup @@ -0,0 +1,4 @@ +type = scripted +command = /usr/lib/chamesle/setup +depends-on = rootfs +restart = false diff --git a/files/etc/dinit.d/single b/files/etc/dinit.d/single @@ -0,0 +1,6 @@ +# "single" on the kernel line: a root shell and nothing else +type = process +command = /usr/lib/chamesle/rescue +options = runs-on-console +restart = false +chain-to = boot diff --git a/files/etc/dinit.d/system b/files/etc/dinit.d/system @@ -0,0 +1,4 @@ +# the file systems, devices and settings every other service needs +type = internal +depends-on = setup +waits-for = udev-trigger diff --git a/files/etc/dinit.d/tty1 b/files/etc/dinit.d/tty1 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty1 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/tty2 b/files/etc/dinit.d/tty2 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty2 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/tty3 b/files/etc/dinit.d/tty3 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty3 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/tty4 b/files/etc/dinit.d/tty4 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty4 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/tty5 b/files/etc/dinit.d/tty5 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty5 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/tty6 b/files/etc/dinit.d/tty6 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty6 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/ttyS0 b/files/etc/dinit.d/ttyS0 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty ttyS0 +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/files/etc/dinit.d/udev-trigger b/files/etc/dinit.d/udev-trigger @@ -0,0 +1,5 @@ +type = scripted +command = /bin/sh -c "udevadm trigger --type=subsystems --action=add; udevadm trigger --type=devices --action=add; udevadm settle -t 5" +depends-on = udevd +depends-on = setup +restart = false diff --git a/files/etc/dinit.d/udevd b/files/etc/dinit.d/udevd @@ -0,0 +1,4 @@ +type = process +command = /sbin/udevd +depends-on = rootfs +smooth-recovery = true diff --git a/files/etc/dinit.d/wpa_supplicant b/files/etc/dinit.d/wpa_supplicant @@ -0,0 +1,4 @@ +type = process +command = /sbin/wpa_supplicant -u -s +depends-on = dbus +smooth-recovery = true diff --git a/files/etc/init.conf b/files/etc/init.conf @@ -1,13 +0,0 @@ -# read by init, rc and service; one setting per line, lists in braces -hostname = chamesle - -# started in this order at boot, stopped in reverse at shutdown -boot-services = {udev,modules,network} - -# kernel modules to load by hand -modules = {evdev,psmouse,i8042,atkbd,usbhid,hid_generic,hid_multitouch,i2c_hid_acpi,xhci_pci,virtio_net,e1000,e1000e,r8169,8139too,igb} - -# $tty is the name of the line; getty-NAME overrides getty for one line -ttys = {tty1,tty2,tty3,tty4,tty5,tty6,ttyS0} -getty = agetty --noclear $tty linux -getty-ttyS0 = agetty -L $tty 115200 vt100 diff --git a/files/etc/init.sh b/files/etc/init.sh @@ -1,20 +0,0 @@ -# conf KEY prints the value of KEY in /etc/init.conf; a {list} comes out separated by spaces -conf() { - _k=$1 _v= _in= - while read -r _l; do - _l=${_l%%#*} - if [ -z "$_in" ]; then - case $_l in *=*) ;; *) continue;; esac - set -- ${_l%%=*} - [ "$1" = "$_k" ] || continue - _l=${_l#*=} - _in=1 - fi - _v="$_v $_l" - case $_v in *\{*) case $_v in *\}*) break;; esac;; *) break;; esac - done < "${INIT_CONF:-/etc/init.conf}" - set -- $_v - case $1 in \{*) _v=${_v//[\{\},]/ };; esac - set -- $_v - echo "$*" -} diff --git a/files/etc/rc b/files/etc/rc @@ -1,30 +0,0 @@ -#!/bin/sh -# run by init at boot -. /etc/init.sh -grep -q " / overlay " /proc/mounts || mount -o remount,rw / || echo "rc: / stays read-only" >&2 -if [ "$1" = autoboot ]; then - fsck -A -R -p -T - case $? in 0|1) ;; *) echo "rc: the file system check failed" >&2; exit 1;; esac -fi -mkdir -p /dev/pts /dev/shm -mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -mountpoint -q /dev/shm || mount -t tmpfs -o mode=1777 tmpfs /dev/shm -[ -d /run/live ] || mountpoint -q /run || mount -t tmpfs tmpfs /run -mount -a -command -v zfs >/dev/null && zfs mount -a -swapon -a -mountpoint -q /tmp || rm -rf /tmp/* /tmp/.[!.]* -chmod 1777 /tmp -hwclock --hctosys --utc 2>/dev/null -mkdir -p /var/log /var/db /var/lib /var/cache /var/tmp -chmod 1777 /var/tmp -[ -e /var/run ] || ln -s ../run /var/run -hwclock -s 2>/dev/null -host=$(conf hostname) -[ -n "$host" ] && echo "$host" > /proc/sys/kernel/hostname -for f in /etc/sysctl.d/*.conf /etc/sysctl.conf; do [ -f "$f" ] && sysctl -q -p "$f"; done -dmesg > /var/log/dmesg.boot -for s in $(conf boot-services); do - service "$s" start -done -exit 0 diff --git a/files/etc/rc.d/NetworkManager b/files/etc/rc.d/NetworkManager @@ -1,5 +0,0 @@ -#!/bin/sh -. /etc/rc.subr -procname=NetworkManager -svc_start() { NetworkManager; } -run "$1" diff --git a/files/etc/rc.d/dbus b/files/etc/rc.d/dbus @@ -1,11 +0,0 @@ -#!/bin/sh -. /etc/rc.subr -procname=dbus-daemon -svc_start() { - mkdir -p /var/lib/dbus /run/dbus - chown messagebus:messagebus /run/dbus - [ -s /var/lib/dbus/machine-id ] || dbus-uuidgen --ensure=/var/lib/dbus/machine-id - rm -f /run/dbus/pid - dbus-daemon --system -} -run "$1" diff --git a/files/etc/rc.d/iwd b/files/etc/rc.d/iwd @@ -1,5 +0,0 @@ -#!/bin/sh -. /etc/rc.subr -procname=iwd -svc_start() { /usr/libexec/iwd & } -run "$1" diff --git a/files/etc/rc.d/modules b/files/etc/rc.d/modules @@ -1,10 +0,0 @@ -#!/bin/sh -. /etc/init.sh -. /etc/rc.subr -svc_start() { - for m in $(conf modules); do - modprobe "$m" || log "cannot load $m" - done -} -svc_stop() { :; } -run "$1" diff --git a/files/etc/rc.d/network b/files/etc/rc.d/network @@ -1,5 +0,0 @@ -#!/bin/sh -. /etc/rc.subr -procname=dhcpcd -svc_start() { mkdir -p /var/db/dhcpcd /run/dhcpcd; dhcpcd -b; } -run "$1" diff --git a/files/etc/rc.d/udev b/files/etc/rc.d/udev @@ -1,11 +0,0 @@ -#!/bin/sh -. /etc/rc.subr -procname=udevd -svc_start() { - udevd --daemon || return - udevadm trigger --type=subsystems --action=add - udevadm trigger --type=devices --action=add - udevadm settle -t 5 -} -svc_stop() { udevadm control --exit; } -run "$1" diff --git a/files/etc/rc.d/wpa_supplicant b/files/etc/rc.d/wpa_supplicant @@ -1,5 +0,0 @@ -#!/bin/sh -. /etc/rc.subr -procname=wpa_supplicant -svc_start() { wpa_supplicant -u -B -s; } -run "$1" diff --git a/files/etc/rc.shutdown b/files/etc/rc.shutdown @@ -1,8 +0,0 @@ -#!/bin/sh -# run by init before it stops: the boot services, last one first -. /etc/init.sh -rev= -for s in $(conf boot-services); do rev="$s $rev"; done -for s in $rev; do - service "$s" stop -done diff --git a/files/etc/rc.subr b/files/etc/rc.subr @@ -1,37 +0,0 @@ -# what a script in /etc/rc.d uses: set procname, define svc_start (and svc_stop, svc_status if the -# defaults do not fit), then call run "$1" -name=${0##*/} - -log() { echo "$name: $*"; } - -# the script itself has the name of the daemon when they share it, so the shell running it is left out -pids() { - _sh=$(readlink /proc/$$/exe) - for _d in /proc/[0-9]*; do - read -r _c 2>/dev/null < $_d/comm && [ "$_c" = "${1:0:15}" ] && [ "$(readlink $_d/exe)" != "$_sh" ] && echo ${_d#/proc/} - done -} - -running() { [ -n "$procname" ] && [ -n "$(pids $procname)" ]; } - -svc_stop() { - running || return 0 - kill $(pids $procname) - _n=0 - while running && [ $_n -lt 10 ]; do sleep 1; _n=$((_n + 1)); done -} - -svc_status() { - [ -n "$procname" ] || { log "nothing to report"; return 0; } - if running; then log "running as pid $(pids $procname)"; else log "not running"; return 1; fi -} - -run() { - case $1 in - start) if running; then log "already running"; else svc_start; fi;; - stop) svc_stop;; - restart) svc_stop; svc_start;; - status) svc_status;; - *) echo "usage: $0 start|stop|restart|status" >&2; exit 2;; - esac -} diff --git a/files/sbin/halt b/files/sbin/halt @@ -1,2 +1,2 @@ #!/bin/sh -exec kill -s USR1 1 +exec /usr/sbin/dinit-halt "$@" diff --git a/files/sbin/init b/files/sbin/init @@ -1,55 +1,10 @@ -#!/bin/mksh -# winchester, pid 1: runs /etc/rc, keeps the gettys of init.conf alive, and stops the machine on a signal. -# INT and TERM reboot, USR1 halts, USR2 powers off -export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin +#!/bin/sh +# mounts what dinit needs before it starts, then hands over to it. "single" on the kernel line starts a root shell instead +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin mountpoint -q /proc || mount -t proc proc /proc mountpoint -q /sys || mount -t sysfs sysfs /sys mountpoint -q /dev || mount -t devtmpfs devtmpfs /dev -exec < /dev/console > /dev/console 2>&1 - -stop= -trap 'stop=reboot' INT TERM -trap 'stop=halt' USR1 -trap 'stop=poweroff' USR2 - +[ -d /run/live ] || mountpoint -q /run || mount -t tmpfs -o mode=755,nosuid,nodev tmpfs /run read -r cmdline < /proc/cmdline -case " $cmdline " in *" single "*) sulogin;; esac -/etc/rc autoboot || sulogin - -. /etc/init.sh -respawn() { - ( - trap - INT TERM USR1 USR2 - while :; do - t=$SECONDS - eval "setsid $2" - [ $((SECONDS - t)) -gt 5 ] || sleep 5 - done - ) & -} -for tty in $(conf ttys); do - [ -c /dev/$tty ] || continue - cmd=$(conf getty-$tty) - respawn $tty "${cmd:-$(conf getty)}" -done - -while [ -z "$stop" ]; do - sleep 86400 & - wait $! - kill $! 2>/dev/null -done - -/etc/rc.shutdown -kill -s TERM -- -1 -sleep 2 -kill -s KILL -- -1 -sync -umount -a -r -[ -e /proc/sysrq-trigger ] || mount -t proc proc /proc -echo 1 > /proc/sys/kernel/sysrq -case $stop in -reboot) echo "rebooting"; echo b > /proc/sysrq-trigger;; -poweroff) echo "powering off"; echo o > /proc/sysrq-trigger;; -esac -echo "halted" -while :; do sleep 86400; done +case " $cmdline " in *" single "*) set -- single;; *) set --;; esac +exec /usr/bin/dinit --system-mgr --auto-recovery "$@" diff --git a/files/sbin/poweroff b/files/sbin/poweroff @@ -1,2 +1,2 @@ #!/bin/sh -exec kill -s USR2 1 +exec /usr/sbin/dinit-poweroff "$@" diff --git a/files/sbin/reboot b/files/sbin/reboot @@ -1,2 +1,2 @@ #!/bin/sh -exec kill -s INT 1 +exec /usr/sbin/dinit-reboot "$@" diff --git a/files/sbin/service b/files/sbin/service @@ -1,25 +1,8 @@ #!/bin/sh -# service -l | -e | name start|stop|restart|status -. /etc/init.sh -dirs="/etc/rc.d /usr/local/etc/rc.d" -find_script() { - for d in $dirs; do - [ -x "$d/$1" ] && { echo "$d/$1"; return 0; } - done - return 1 -} +# service NAME start|stop|restart|status|enable|disable, service -l: dinitctl, the old way round case $1 in --l) - for d in $dirs; do - for f in $d/*; do if [ -x "$f" ]; then echo "${f##*/}"; fi; done - done;; --e) - for s in $(conf boot-services); do - find_script "$s" || echo "service: $s: no such service" >&2 - done;; --*|'') echo "usage: service -l | -e | name start|stop|restart|status" >&2; exit 2;; -*) - s=$(find_script "$1") || { echo "service: $1: no such service" >&2; exit 1; } - shift - exec "$s" "$@";; +-l) exec dinitctl list;; +-*|'') echo "usage: service -l | NAME start|stop|restart|status|enable|disable" >&2; exit 2;; esac +[ $# = 2 ] || { echo "usage: service -l | NAME start|stop|restart|status|enable|disable" >&2; exit 2; } +exec dinitctl "$2" "$1" diff --git a/files/sbin/shutdown b/files/sbin/shutdown @@ -2,9 +2,9 @@ # shutdown -r|-h|-p [now|+minutes] [message] usage() { echo "usage: shutdown -r|-h|-p [now|+minutes] [message]" >&2; exit 2; } case $1 in --r) sig=INT;; --h) sig=USR1;; --p) sig=USR2;; +-r) how=reboot;; +-h) how=halt;; +-p) how=poweroff;; *) usage;; esac shift @@ -15,4 +15,4 @@ now) ;; +[0-9]*) [ $# -gt 0 ] && wall "$*"; sleep $((${when#+} * 60));; *) usage;; esac -exec kill -s $sig 1 +exec /usr/sbin/dinit-$how diff --git a/files/usr/lib/chamesle/dbus b/files/usr/lib/chamesle/dbus @@ -0,0 +1,7 @@ +#!/bin/sh +# the system bus, in the foreground for dinit +mkdir -p /var/lib/dbus /run/dbus +chown messagebus:messagebus /run/dbus +[ -s /var/lib/dbus/machine-id ] || /usr/bin/dbus-uuidgen --ensure=/var/lib/dbus/machine-id +rm -f /run/dbus/pid +exec /usr/bin/dbus-daemon --system --nofork --nopidfile diff --git a/files/usr/lib/chamesle/dhcpcd b/files/usr/lib/chamesle/dhcpcd @@ -0,0 +1,3 @@ +#!/bin/sh +mkdir -p /var/db/dhcpcd /run/dhcpcd +exec /sbin/dhcpcd -B diff --git a/files/usr/lib/chamesle/getty b/files/usr/lib/chamesle/getty @@ -0,0 +1,10 @@ +#!/bin/sh +# getty TTY: a login on TTY. a serial port the machine does not have gets no getty, instead of one failing over and over +t=$1 +shift +case $t in +ttyS*) + grep -q "^${t#ttyS}: uart:unknown" /proc/tty/driver/serial 2>/dev/null && exec sleep 2147483647 + exec /sbin/agetty "$@" -L $t 115200 vt100;; +*) exec /sbin/agetty "$@" --noclear $t linux;; +esac diff --git a/files/usr/lib/chamesle/rescue b/files/usr/lib/chamesle/rescue @@ -0,0 +1,5 @@ +#!/bin/sh +# a root shell on the console, when the boot cannot go on +command -v sulogin >/dev/null && exec sulogin +echo "a root shell; exit to go on" +exec /bin/mksh -l diff --git a/files/usr/lib/chamesle/rootfs b/files/usr/lib/chamesle/rootfs @@ -0,0 +1,27 @@ +#!/bin/sh +# at boot, before any service: checks and mounts the file systems. a failed check gives a root shell +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +mkdir -p /dev/pts /dev/shm +mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts +mountpoint -q /dev/shm || mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm +mountpoint -q /sys/fs/cgroup || mount -t cgroup2 -o nsdelegate cgroup2 /sys/fs/cgroup +if ! grep -q " / overlay " /proc/mounts; then + read -r cmdline < /proc/cmdline + case " $cmdline " in + *" fastboot "*) ;; + *) + fsck -A -R -p -T + case $? in 0|1) ;; *) echo "the file system check failed, fix it in this shell and exit to go on"; /usr/lib/chamesle/rescue;; esac + ;; + esac + mount -o remount,rw / || echo "/ stays read-only" +fi +mount -a +command -v zfs >/dev/null && zfs mount -a +swapon -a +mountpoint -q /tmp || rm -rf /tmp/* /tmp/.[!.]* +chmod 1777 /tmp +mkdir -p /var/log /var/db /var/lib /var/cache /var/tmp +chmod 1777 /var/tmp +[ -e /var/run ] || ln -s ../run /var/run +exit 0 diff --git a/files/usr/lib/chamesle/setup b/files/usr/lib/chamesle/setup @@ -0,0 +1,12 @@ +#!/bin/sh +# at boot, once the file systems are there: clock, host name, kernel settings and modules +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ip link set lo up +hwclock --hctosys --utc 2>/dev/null +[ -s /etc/hostname ] && read -r host < /etc/hostname && echo "$host" > /proc/sys/kernel/hostname +for f in /etc/sysctl.d/*.conf /etc/sysctl.conf; do [ -f "$f" ] && sysctl -q -p "$f"; done +cat /usr/lib/modules-load.d/*.conf /etc/modules-load.d/*.conf /etc/modules 2>/dev/null | sed 's/#.*//' | while read -r m args; do + [ -n "$m" ] && modprobe "$m" $args 2>/dev/null +done +dmesg > /var/log/dmesg.boot +exit 0 diff --git a/files/usr/lib/modules-load.d/chamesle.conf b/files/usr/lib/modules-load.d/chamesle.conf @@ -0,0 +1,15 @@ +evdev +psmouse +i8042 +atkbd +usbhid +hid_generic +hid_multitouch +i2c_hid_acpi +xhci_pci +virtio_net +e1000 +e1000e +r8169 +8139too +igb diff --git a/handbook/handbook.md b/handbook/handbook.md @@ -29,7 +29,7 @@ The parts: | mag | the package manager, binary packages only, in one C file | | rifle | the coreutils, all in one C file; `cat`, `ls`, `cp` and the rest are links to one program | | mksh | the login shell; `/bin/sh` is busybox's ash | -| init | Winchester, `/sbin/init`, a shell script that runs under mksh, in the style of FreeBSD's: `/etc/rc`, `/etc/init.conf`, services | +| init | dinit, with Chamesle's services in `/etc/dinit.d` | | limine | the boot loader, BIOS and UEFI | Chamesle is made to be the most UNIX distribution possible, and to run on almost anything: the same base goes on a new @@ -39,7 +39,7 @@ laptop and on a Pentium 4 with 256 MB of memory. It is a system for the tty firs mag reads two kinds of repository, both signed: -* Chamesle's own, at `https://chamesle.org/repo`: `chamesle-base` (Winchester, `/etc/rc`, the services, the tools of this +* Chamesle's own, at `https://chamesle.org/repo`: `chamesle-base` (the dinit services, the tools of this book and the keys), `mag` and `rifle` * a large musl repository with everything else: the kernel, the firmware, the libraries, editors, compilers, X, about 28,000 packages for x86_64 @@ -197,7 +197,7 @@ Packages after the target go in too. A ThinkPad with Intel wireless and graphics chamesle-bootstrap -n t480 -f linux-firmware-intel /mnt vim -What `chamesle-base` brings: Winchester and the files of chapter 6, mag, rifle, mksh, busybox for the tools rifle does not +What `chamesle-base` brings: dinit and the files of chapter 6, mag, rifle, mksh, busybox for the tools rifle does not have, `agetty`, eudev, kmod, dhcpcd, e2fsprogs and curl. ### 3.4 Working inside the new root @@ -230,7 +230,7 @@ A root on ZFS gets no root line. ### 3.6 Host name and password -The host name is in `/mnt/etc/init.conf`, from `-n`. Set the root password: +The host name is in `/mnt/etc/hostname`, from `-n`. Set the root password: chamesle-chroot /mnt passwd root @@ -306,8 +306,8 @@ Do both and the disk boots either way. Leave out `zpool export` if the root is not on ZFS. -Take out the installation medium. limine shows the entry for three seconds and boots the kernel. `init` runs `/etc/rc`, which mounts the -file systems and starts the services of `init.conf`, and puts a login on the ttys. Log in as root. `dhcpcd` brings up a +Take out the installation medium. limine shows the entry for three seconds and boots the kernel. dinit mounts the +file systems, starts the services of `/etc/dinit.d/boot.d` and puts a login on the ttys. Log in as root. `dhcpcd` brings up a cable at boot; for wireless see section 6.8. ### 3.9 What to install next @@ -549,88 +549,65 @@ not. `./build.sh` has to have run first. A case that starts with `@ro` runs with ### 6.1 init -The init is called Winchester. `/sbin/init` is a mksh script, and it works the way FreeBSD's init does: the kernel starts it as process 1, it runs -`/etc/rc`, then it keeps a getty on every tty and waits for a signal. The files are in `files/` in the sources and -`chamesle-bootstrap` copies them into the root. Step by step: +The init is dinit. `/sbin/init` is a short script: it mounts `proc`, `sysfs`, `devtmpfs` and `/run`, and hands over +to `dinit`, which stays process 1. dinit starts the service called `boot` and everything it needs, keeps the +services running, and stops them all in order when the machine goes down. The files are in `files/` in the sources and +`chamesle-bootstrap` copies them into the root. -1. `PATH` is set to `/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin`. `proc`, `sysfs` and `devtmpfs` - are mounted if they are not yet, and what init prints goes to `/dev/console`. -2. If `single` is on the kernel command line, init runs `sulogin` first. -3. `/etc/rc autoboot` runs (6.2). If it fails, init runs `sulogin` and goes on when you leave it. -4. For every name in `ttys` of `init.conf` that has a node in `/dev`, init starts a loop that runs the getty command - again whenever it exits. A getty that dies within five seconds is run again after a pause of five. -5. init waits. A signal ends the wait: +A boot goes: -| signal | what it does | -|--------|--------------| -| `INT`, `TERM` | reboot | -| `USR1` | halt: stop everything and stay stopped | -| `USR2` | power off | +1. `rootfs`: `fsck` checks the file systems (not with `fastboot` on the kernel command line), `/` is remounted + read-write, `devpts`, `/dev/shm` and the cgroup2 hierarchy are mounted, `mount -a` mounts `/etc/fstab`, `zfs mount -a` + mounts the ZFS datasets, `swapon -a`, and `/tmp` is emptied. A failed check gives a root shell; leave it to go on. +2. `udevd`, then `setup`: loopback up, the clock, the host name from `/etc/hostname`, `/etc/sysctl.d/*.conf`, the + modules (6.6), and `dmesg` into `/var/log/dmesg.boot`. +3. `udev-trigger` replays the devices and waits for them. +4. Every service in `/etc/dinit.d/boot.d`, all at once, each after what it depends on. -6. Then it runs `/etc/rc.shutdown`, sends `TERM` to every process, `KILL` two seconds later, runs `sync`, `umount -a -r` - and does the last step through `/proc/sysrq-trigger` (`b` or `o`). That needs `CONFIG_MAGIC_SYSRQ` in the kernel; - the base set has no `reboot` program of its own that calls the kernel. +`single` on the kernel command line starts a root shell and nothing else; the boot goes on when you leave it. If the +boot fails, dinit starts a root shell too. -### 6.2 rc, init.conf and the services +### 6.2 Services -`/etc/rc` mounts the system. In order: `/` is remounted read-write; with `autoboot`, `fsck -A -R -p` checks the -other file systems; `devpts` and `/dev/shm` are mounted; a tmpfs goes on `/run` (not on the live ISO, where -`/run/live` is already there); `mount -a` mounts `/etc/fstab`; `swapon -a`; `/tmp` is emptied if it is not a mount and -set to mode 1777; the host name is set; `dmesg` is saved in `/var/log/dmesg.boot`. Then every service in -`boot-services` is started, in the order it is written. +A service is a file in `/etc/dinit.d` named after it. The base set has `dbus`, `dhcpcd`, `elogind`, `gdm`, `iwd`, +`NetworkManager`, `wpa_supplicant` and the logins `tty1` to `tty6` and `ttyS0`, for when those packages are installed. +`dinitctl` does the rest: -`/etc/init.conf` is the one configuration file. One setting per line, `key = value`, `#` starts a comment, blank -lines are ignored, spaces around `=` are free. A list is in braces and may go over several lines: + dinitctl list every service that is loaded, and its state + dinitctl start iwd + dinitctl stop iwd + dinitctl restart dhcpcd + dinitctl status dbus + dinitctl enable NetworkManager start it now and at every boot + dinitctl disable dhcpcd not at boot any more - hostname = chamesle +`enable` and `disable` make and remove a link in `/etc/dinit.d/boot.d`; that directory is the list of what starts +at boot. A fresh install has `dhcpcd` and `tty1` to `tty6` in it. `service NAME start` and the rest still work and +run `dinitctl`. - # started in this order at boot, stopped in reverse at shutdown - boot-services = {udev,modules,network} +A service whose process dies is started again, unless it dies over and over in a few seconds; then dinit gives up and +`dinitctl list` shows it stopped. To add a service, write its file. A daemon that can stay in the foreground is a +`process`: - modules = {} - ttys = {tty1,tty2,tty3,tty4,tty5,tty6,ttyS0} - getty = agetty --noclear $tty linux - getty-ttyS0 = agetty -L $tty 115200 vt100 + # /etc/dinit.d/chronyd + type = process + command = /usr/sbin/chronyd -d + depends-on = system + smooth-recovery = true -| key | meaning | -|-----|---------| -| `hostname` | the host name | -| `boot-services` | the services started at boot, in order; shutdown stops them in reverse | -| `modules` | kernel modules the `modules` service loads with `modprobe` | -| `ttys` | the ttys that get a getty | -| `getty` | the getty command; `$tty` is the tty name | -| `getty-NAME` | the getty command for that tty alone | - -The parser is `conf` in `/etc/init.sh`; `conf KEY` prints the value, with a list separated by spaces. A change to -`ttys` or `getty` takes effect at the next boot. - -A service is an executable file in `/etc/rc.d` (or `/usr/local/etc/rc.d`, for the ones you add) that takes -`start`, `stop`, `restart` or `status`. The base set has `udev` (starts `udevd`, replays the devices and waits -for them), `modules`, `network` (`dhcpcd`), and `dbus`, `iwd` and `NetworkManager` for when those packages are installed. A name in `boot-services` without a script is skipped with one line -saying so. - -`service` is the way to run them: - - service -l every service - service -e the services of boot-services, as paths - service network restart - service udev status - -To add a service, write the script, make it executable, and put its name in `boot-services`. With -`/etc/rc.subr` it is short. Set `procname` to the name the process shows in `/proc/PID/comm`, write -`svc_start`, and finish with `run "$1"`; `stop` then kills that process, `status` looks for it and `start` refuses to -start it twice. Override `svc_stop` and `svc_status` if the defaults do not fit: - - #!/bin/sh - . /etc/rc.subr - procname=chronyd - svc_start() { chronyd; } - run "$1" +`depends-on = system` waits for the file systems and devices; `depends-on = dbus` for the system bus. `dinit-service(5)` +has every setting. + +Chamesle before base r18 ran Winchester, a shell init with `/etc/init.conf` and scripts in `/etc/rc.d`. The upgrade +to r18 moves you over by itself: the host name goes to `/etc/hostname`, the services of `boot-services` and the +`ttys` are enabled in dinit (`network` is `dhcpcd` now, `udev` and `modules` are part of the boot), and `init.conf` +is kept as `/etc/init.conf.old`. A changed `getty` line is not carried over; edit `/etc/dinit.d/ttyN` for that. ### 6.3 Shutting down -`reboot`, `halt` and `poweroff` send `INT`, `USR1` and `USR2` to init. `shutdown -r`, `-h` or `-p` does the same, at -once (`now`) or after `+minutes`, with an optional message sent through `wall`: +`reboot`, `halt` and `poweroff` ask dinit to stop. It stops the services, the ones others depend on last, sends +`TERM` and then `KILL` to what is left, turns swap off, unmounts the file systems and powers off. `shutdown -r`, `-h` or +`-p` does the same, at once (`now`) or after `+minutes`, with an optional message sent through `wall`: shutdown -r now shutdown -p +10 back in ten minutes @@ -641,7 +618,9 @@ once (`now`) or after `+minutes`, with an optional message sent through `wall`: |------|---------------| | `passwd`, `shadow`, `group` | accounts, password hashes, groups | | `shells` | the login shells; `/bin/mksh` is one | -| `init.conf` | host name, boot services, modules, ttys (6.2) | +| `hostname` | the host name | +| `dinit.d/` | the services, and in `boot.d` the ones started at boot (6.2) | +| `modules` | kernel modules loaded at boot, one a line | | `fstab` | the file systems (3.5) | | `profile` | `PATH`, `PAGER`, `umask 022`, and `/etc/profile.d/*.sh` | | `os-release` | `NAME=Chamesle`, `ID=chamesle` | @@ -671,11 +650,11 @@ whoever runs X or a Wayland compositor needs both, or Xorg stops with `open /dev eudev is the udev. `udevd` gives devices their nodes in `/dev` and loads the modules the hardware needs. kmod provides `modprobe`, `insmod`, `rmmod`, `lsmod`, `modinfo` and `depmod`. A kernel's modules are in -`/lib/modules/VERSION`. To load one by hand: `modprobe name`. To load one at every boot, put its name in `modules` of `/etc/init.conf`. To keep one from loading, put `blacklist name` in a file in `/etc/modprobe.d/`. +`/lib/modules/VERSION`. To load one by hand: `modprobe name`. To load one at every boot, put its name on a line of `/etc/modules`. The base loads the input and network drivers of `/usr/lib/modules-load.d/chamesle.conf` too. To keep one from loading, put `blacklist name` in a file in `/etc/modprobe.d/`. ### 6.7 Networking -`dhcpcd` is the DHCP client and is in the base set. It is the `network` service, in `boot-services` by default, and takes +`dhcpcd` is the DHCP client and is in the base set. It is the `dhcpcd` service, enabled by default, and takes every interface, so a cable is up at boot. `ip` lists them: ip addr @@ -687,7 +666,7 @@ A static address: ip route add default via 192.168.1.1 echo 'nameserver 192.168.1.1' > /etc/resolv.conf -and take `network` out of `boot-services`. +and `dinitctl disable dhcpcd`. ### 6.8 Wireless @@ -695,11 +674,11 @@ The card needs its firmware (7.4). Then iwd: mag install iwd dbus -and put `dbus` and `iwd` in `boot-services` before `network`: +and enable it, which starts dbus with it: - boot-services = {udev,modules,dbus,iwd,network} + dinitctl enable iwd -`service dbus start`, `service iwd start` to have them now. `iwctl` connects, the same as on the ISO (2.3), and remembers +`iwctl` connects, the same as on the ISO (2.3), and remembers the network. dhcpcd gives it an address. `wpa_supplicant` works too, for those who know it: `mag install wpa_supplicant`. @@ -713,12 +692,12 @@ the network. dhcpcd gives it an address. `mount` and `umount` are busybox's; `lsblk`, `blkid`, `sfdisk` and `cfdisk` are packages of their own, `mkfs.ext4` and `fsck.ext4` are e2fsprogs', `mkfs.fat` is dosfstools', `zpool` and `zfs` are `zfs`. -On a ZFS root, `/etc/rc` runs `zfs mount -a` right after `mount -a`, which mounts `rpool/home` and `rpool/var`; the root itself was +On a ZFS root, the boot runs `zfs mount -a` right after `mount -a`, which mounts `rpool/home` and `rpool/var`; the root itself was mounted by the initramfs. ### 6.10 Kernel settings -`/etc/rc` loads every `/etc/sysctl.d/*.conf` and `/etc/sysctl.conf` at boot. The base ships +The boot loads every `/etc/sysctl.d/*.conf` and `/etc/sysctl.conf` at boot. The base ships `/etc/sysctl.d/10-chamesle.conf`: kernel addresses and `dmesg` are for root only (`doas dmesg`), a process may `ptrace` only its own children, users get no BPF, links and files in sticky directories like `/tmp` are protected, setuid programs leave no core dumps, and the network takes no redirects or source routes and filters spoofed @@ -878,7 +857,7 @@ A changed file under `/etc` is never written over. When a package brings a new o | a BIOS machine does not boot | `limine bios-install /dev/sda` was not run, or `limine-bios.sys` is not in `/boot` | | a UEFI machine does not boot | `EFI/BOOT/BOOTX64.EFI` is not on the EFI partition, or the partition is not of type EFI System | | no wireless interface | the firmware is missing (7.4); `dmesg` names the file | -| no devices in `/dev` | udev did not start; check `udev` is in `boot-services` | +| no devices in `/dev` | udev did not start; `dinitctl status udevd` | ## 10. X and a window manager @@ -955,7 +934,7 @@ left. Drag a program's icon to the dock to keep it there. `WPrefs` changes the r mag install firefox `firefox-esr` is the long-term one. Firefox and many other programs want a D-Bus session; with `dbus` and `dbus-x11` -installed and `dbus` in `boot-services` (6.8), start the window manager inside one: +installed and `dbus` enabled (6.2), start the window manager inside one: exec dbus-launch --exit-with-session wmaker @@ -978,9 +957,10 @@ X writes `~/.local/share/xorg/Xorg.0.log`; `grep EE` in it shows the errors. | path | what | |------|------| -| `/sbin/init`, `/etc/rc`, `/etc/rc.shutdown` | init, the boot script, the shutdown script, all run by mksh | -| `/etc/init.conf` | host name, boot services, modules, ttys | -| `/etc/rc.d/`, `/usr/local/etc/rc.d/` | the service scripts | +| `/sbin/init` | mounts what dinit needs and starts it | +| `/etc/dinit.d/`, `/etc/dinit.d/boot.d/` | the services, and the ones started at boot | +| `/usr/lib/chamesle/` | the boot scripts the services run | +| `/etc/hostname`, `/etc/modules` | host name, modules loaded at boot | | `/etc/profile` | `PATH`, `umask` | | `/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/shells` | accounts, passwords, groups, login shells | | `/etc/fstab` | file systems | @@ -1008,7 +988,7 @@ X writes `~/.local/share/xorg/Xorg.0.log`; `grep EE` in it shows the errors. | `system/tools/chamesle-boot` | limine.conf and limine for the system in a directory | | `system/tools/chamesle-disk` | cfdisk, vfat boot partition, ZFS root, mounted on `/mnt` | | `system/tools/mkapk`, `mkrepo`, `mkpkgs` | packages, signed indexes, Chamesle's own repo | -| `system/files/` | init, rc, `service`, `init.conf` and the service scripts, in `chamesle-base` | +| `system/files/` | `/sbin/init`, the dinit services and boot scripts, `service`, in `chamesle-base` | | `system/pkg/chamesle-base/` | its scripts, `repos`, `os-release`, `issue` | | `system/keys/` | the public keys the repos are signed with | | `system/iso/mkiso`, `mkinitramfs`, `init` | the live ISO, its initramfs and the first process in it | diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/dbus b/iso/profile/overlay/etc/dinit.d/boot.d/dbus @@ -0,0 +1 @@ +../dbus +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/dhcpcd b/iso/profile/overlay/etc/dinit.d/boot.d/dhcpcd @@ -0,0 +1 @@ +../dhcpcd +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/iwd b/iso/profile/overlay/etc/dinit.d/boot.d/iwd @@ -0,0 +1 @@ +../iwd +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/tty1 b/iso/profile/overlay/etc/dinit.d/boot.d/tty1 @@ -0,0 +1 @@ +../tty1 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/tty2 b/iso/profile/overlay/etc/dinit.d/boot.d/tty2 @@ -0,0 +1 @@ +../tty2 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/tty3 b/iso/profile/overlay/etc/dinit.d/boot.d/tty3 @@ -0,0 +1 @@ +../tty3 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/tty4 b/iso/profile/overlay/etc/dinit.d/boot.d/tty4 @@ -0,0 +1 @@ +../tty4 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/tty5 b/iso/profile/overlay/etc/dinit.d/boot.d/tty5 @@ -0,0 +1 @@ +../tty5 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/tty6 b/iso/profile/overlay/etc/dinit.d/boot.d/tty6 @@ -0,0 +1 @@ +../tty6 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/boot.d/ttyS0 b/iso/profile/overlay/etc/dinit.d/boot.d/ttyS0 @@ -0,0 +1 @@ +../ttyS0 +\ No newline at end of file diff --git a/iso/profile/overlay/etc/dinit.d/tty1 b/iso/profile/overlay/etc/dinit.d/tty1 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty1 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/dinit.d/tty2 b/iso/profile/overlay/etc/dinit.d/tty2 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty2 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/dinit.d/tty3 b/iso/profile/overlay/etc/dinit.d/tty3 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty3 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/dinit.d/tty4 b/iso/profile/overlay/etc/dinit.d/tty4 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty4 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/dinit.d/tty5 b/iso/profile/overlay/etc/dinit.d/tty5 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty5 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/dinit.d/tty6 b/iso/profile/overlay/etc/dinit.d/tty6 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty tty6 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/dinit.d/ttyS0 b/iso/profile/overlay/etc/dinit.d/ttyS0 @@ -0,0 +1,6 @@ +type = process +command = /usr/lib/chamesle/getty ttyS0 --autologin root +depends-on = system +restart = true +restart-delay = 2 +termsignal = HUP diff --git a/iso/profile/overlay/etc/hostname b/iso/profile/overlay/etc/hostname @@ -0,0 +1 @@ +chamesle-live diff --git a/iso/profile/overlay/etc/init.conf b/iso/profile/overlay/etc/init.conf @@ -1,7 +0,0 @@ -# the live system's: root is logged in on every tty -hostname = chamesle-live -boot-services = {udev,modules,dbus,iwd,network} -modules = {evdev,psmouse,i8042,atkbd,usbhid,hid_generic,hid_multitouch,i2c_hid_acpi,xhci_pci,virtio_net,e1000,e1000e,r8169,8139too,igb,iwlwifi} -ttys = {tty1,tty2,tty3,tty4,tty5,tty6,ttyS0} -getty = agetty --autologin root --noclear $tty linux -getty-ttyS0 = agetty --autologin root -L $tty 115200 vt100 diff --git a/pkg/chamesle-base/post-install b/pkg/chamesle-base/post-install @@ -5,4 +5,5 @@ Chamesle. The handbook is /usr/share/doc/chamesle/handbook.md, mag help says how M sed -i 's|^root:\([^:]*\):0:0:\([^:]*\):/root:/bin/sh$|root:\1:0:0:\2:/root:/bin/mksh|' /etc/passwd grep -qx /bin/mksh /etc/shells || echo /bin/mksh >> /etc/shells +mkdir -p /etc/dinit.d/boot.d exit 0 diff --git a/pkg/chamesle-base/pre-upgrade b/pkg/chamesle-base/pre-upgrade @@ -0,0 +1,13 @@ +#!/bin/sh +# from Winchester to dinit, once: the host name to /etc/hostname, the boot services and logins of init.conf enabled in dinit +[ -f /etc/init.conf ] || exit 0 +mkdir -p /etc/dinit.d/boot.d +conf() { sed -n "s/^$1 *= *//p" /etc/init.conf | tr -d '{}' | tr ',' ' '; } +h=$(conf hostname) +[ -n "$h" ] && { [ ! -s /etc/hostname ] || [ "$(cat /etc/hostname)" = localhost ]; } && echo "$h" > /etc/hostname +for s in $(conf boot-services) $(conf ttys); do + case $s in udev|modules) continue;; network) s=dhcpcd;; esac + ln -sf ../$s /etc/dinit.d/boot.d/$s +done +cp /etc/init.conf /etc/init.conf.old +exit 0 diff --git a/tools/chamesle-bootstrap b/tools/chamesle-bootstrap @@ -39,6 +39,8 @@ mag update # the kernel wants some firmware; the vendor packages do not count as that, so -none goes with them case $firmware in linux-firmware|linux-firmware-none) ;; *) firmware="linux-firmware-none $firmware";; esac mag install chamesle-base $firmware $kernel "$@" -sed -i "s/^hostname = .*/hostname = $name/" "$target/etc/init.conf" +echo "$name" > "$target/etc/hostname" +mkdir -p "$target/etc/dinit.d/boot.d" +for s in tty1 tty2 tty3 tty4 tty5 tty6 dhcpcd; do ln -sf ../$s "$target/etc/dinit.d/boot.d/$s"; done echo echo "the base is in $target. go on with the fstab, a password and the boot entry (handbook, 3.4)." diff --git a/tools/mkpkgs b/tools/mkpkgs @@ -16,7 +16,7 @@ mkdir -p "$tmp/mag/usr/bin" install -m755 "$MAG" "$tmp/mag/usr/bin/mag" mkapk -n mag -v "$("$MAG" --version | cut -d' ' -f2)" -d "the package manager" "$tmp/mag" -deps="alpine-baselayout busybox busybox-binsh busybox-suid doas mksh agetty eudev kmod dhcpcd e2fsprogs dosfstools curl mag" +deps="alpine-baselayout busybox busybox-binsh busybox-suid doas mksh agetty dinit dinit-shutdown eudev kmod dhcpcd e2fsprogs dosfstools curl mag" if [ -n "$RIFLE" ]; then mkdir -p "$tmp/rifle/usr/bin" install -m755 "$RIFLE" "$tmp/rifle/usr/bin/rifle" @@ -35,7 +35,7 @@ cp "$here/pkg/chamesle-base/repos" "$b/etc/mag/repos" cp "$here/pkg/chamesle-base/os-release" "$here/pkg/chamesle-base/issue" "$b/etc/" for t in chamesle-bootstrap chamesle-chroot chamesle-disk chamesle-boot; do install -m755 "$here/tools/$t" "$b/usr/bin/$t"; done cp "$here/handbook/handbook.md" "$b/usr/share/doc/chamesle/handbook.md" -mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "Winchester, the files in /etc and the tools of Chamesle" \ +mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "dinit's services, the files in /etc and the tools of Chamesle" \ -D "$deps" -s "$here/pkg/chamesle-base" "$b" if [ -n "$WMREL" ]; then