commit 3a90da4053dc5723d4c2c222fc2c2f4092580ee6
parent 3b0c7264bb1cd2f48dafa555cf11423ea4f9e1c8
Author: mrgrouse <bdmfegys@duck.com>
Date: Sun, 27 Jul 2025 20:14:16 -0400
create rc.init and add psuedo-fs and swap mounting, along with hostname setting and starting svc.
Diffstat:
| A | sinit/rc.init | | | 54 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 54 insertions(+), 0 deletions(-)
diff --git a/sinit/rc.init b/sinit/rc.init
@@ -0,0 +1,54 @@
+#!/bin/execlineb
+#importas -S PATH
+define PATH "/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin"
+
+background { printf "Starting Suckless' init!\n\nMounting from /etc/fstab...\n" }
+foreground { mount -a }
+
+# --- beginning of mounter --- #
+# the following is inspired by getopt in c, meant to make adding different mountpoints to this easier
+forx x { /proc /sys /sys/firmware/efi/efivars /dev /dev/pts /dev/shm /run /tmp }
+{ # begin loop
+foreground { # foreground wrapper
+ case -N -- $x
+ { # open case
+ /proc { export mntargs "proc proc ${x} -o nosuid,noexec,nodev" }
+ /sys { export mntargs "sysfs sysfs ${x} -o nosuid,noexec,nodev" }
+ /sys/firmware/efi/efivars { export mntargs "efivarfs -o ro efivarfs ${x}" }
+ /dev { export mntargs "devtmpfs devtmpfs ${x} -o mode=0755,nosuid" }
+ /dev/pts { export mntargs "devpts devpts ${x} -o mode=0620,gid=5,nosuid,noexec" }
+ /dev/shm { export mntargs "tmpfs tmpfs ${x} -o mode=1777,nosuid,nodev" }
+ /run { export mntargs "tmpfs tmpfs ${x} -o mode=0755,nosuid,nodev" }
+ /tmp { export mntargs "tmpfs tmpfs ${x}" }
+ } # close case
+
+ # default case if one of the things above does not match. TODO: dropping into shell may not work depending on the shell, maybe we should just trigger reboot
+ {
+ foreground
+ { printf "Broken forx mounter loop at %s. Fix %s.\nDropping into shell." ${x} ${0} }
+ exec /bin/sh
+ }
+
+} # close foreground wrapper (around case statement)
+
+# if said dir is a mountpoint
+importas -S mntargs
+if { ! mountpoint -q ${x} }
+ { mount -t ${mntargs} }
+
+} # close forx
+
+# --- end of mounter --- #
+
+background { printf "Mounting swap devices...\n" }
+foreground { swapon -a }
+
+background { printf "Setting up hostname...\n" }
+foreground {
+ if { eltest $hostname }
+ {
+ redirfd -w 1 /proc/sys/kernel/hostname { echo ${hostname} }
+ }
+}
+background { printf "Starting svc services...\n" }
+exec { svc -s }