aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPS <p@0x53.net>2026-02-01 12:06:01 +0100
committerPS <p@0x53.net>2026-02-01 12:06:01 +0100
commit0f936e1351d95d7b7bb8ac4b64fc2a87f2982d8c (patch)
tree30e5af481a10ad099076ec172542a8dc8ffeea58 /src
downloadgoetia-freebsd-init-0f936e1351d95d7b7bb8ac4b64fc2a87f2982d8c.tar.gz
goetia-freebsd-init-0f936e1351d95d7b7bb8ac4b64fc2a87f2982d8c.tar.bz2
goetia-freebsd-init-0f936e1351d95d7b7bb8ac4b64fc2a87f2982d8c.zip
version 0.2.0.0
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bin/system-init29
-rwxr-xr-xsrc/bin/system-shutdown14
-rw-r--r--src/lib/service/system/goetia-shutdown/down0
-rwxr-xr-xsrc/lib/service/system/goetia-shutdown/run7
-rw-r--r--src/lib/service/system/goetia-shutdown/stage3b14
-rw-r--r--src/lib/service/system/goetia-shutdown/stage414
6 files changed, 78 insertions, 0 deletions
diff --git a/src/bin/system-init b/src/bin/system-init
new file mode 100755
index 0000000..59ca114
--- /dev/null
+++ b/src/bin/system-init
@@ -0,0 +1,29 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+redirfd -a 1 /dev/console
+redirfd -a 2 /dev/console
+
+multisubstitute {
+ importas -SD default BUNDLE
+ importas -SD
+ /command:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/libexec:/usr/local/libexec
+ PATH
+}
+export PATH ${PATH}
+
+execline-cd /
+s6-setsid
+
+if { mount -t tmpfs -o mode=0755 tmpfs @tmpfsdir@ }
+
+prepare-svscan
+ @sysconfdir@
+ @tmpfsdir@/@sysrundir@
+ ${BUNDLE}
+
+foreground { mkdir -p -- @tmpfsdir@/@sysrundir@/log }
+foreground { cp -Rpf -- @syslogdir@/uncaught-logs @tmpfsdir@/@sysrundir@/log/ }
+
+s6-svscan @tmpfsdir@/@sysrundir@/service
diff --git a/src/bin/system-shutdown b/src/bin/system-shutdown
new file mode 100755
index 0000000..53b2d4b
--- /dev/null
+++ b/src/bin/system-shutdown
@@ -0,0 +1,14 @@
+#!@shebangdir@/execlineb -s0
+
+# ISC license.
+
+ifelse { eltest \\\\${@} =~ ^-[hpr]$ } {
+ if { mkdir -p @tmpfsdir@/@sysrundir@/shutdown-directive }
+ if {
+ redirfd -w 1 @tmpfsdir@/@sysrundir@/shutdown-directive/DIRECTIVE
+ echo ${@}
+ }
+ s6-svc -U @tmpfsdir@/@sysrundir@/service/goetia-shutdown
+}
+if { echo "system-shutdown: usage: system-shutdown -h | -p | -r" }
+exit 100
diff --git a/src/lib/service/system/goetia-shutdown/down b/src/lib/service/system/goetia-shutdown/down
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/down
diff --git a/src/lib/service/system/goetia-shutdown/run b/src/lib/service/system/goetia-shutdown/run
new file mode 100755
index 0000000..32f37fe
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/run
@@ -0,0 +1,7 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+fdmove -c 2 1
+
+system-shutdown-daemon
diff --git a/src/lib/service/system/goetia-shutdown/stage3b b/src/lib/service/system/goetia-shutdown/stage3b
new file mode 100644
index 0000000..3daf81f
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/stage3b
@@ -0,0 +1,14 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+if -n {
+ tryexec { ./stage4 }
+ foreground { chmod u+x stage4 }
+
+ foreground { kill -SIGCONT -- -1 }
+ foreground { sleep 1 }
+ foreground { echo sending all processes the KILL signal... }
+ foreground { kill -SIGKILL -- -1 }
+}
+chmod a-x stage3b stage4
diff --git a/src/lib/service/system/goetia-shutdown/stage4 b/src/lib/service/system/goetia-shutdown/stage4
new file mode 100644
index 0000000..d8e8bcc
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/stage4
@@ -0,0 +1,14 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+if -n {
+ s6-envdir -I @tmpfsdir@/@sysrundir@/shutdown-directive
+ importas -SD "-r" DIRECTIVE
+
+ foreground { umount -A }
+ foreground { mount -ur / }
+
+ shutdown -o ${DIRECTIVE} now
+}
+chmod a-x stage3b stage4