aboutsummaryrefslogtreecommitdiff
path: root/container/init
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2026-09-15 14:05:52 +0200
committerNicholas Rodrigues Lordello <[email protected]>2026-09-15 14:05:52 +0200
commit717968007c67fca3067777cffa3dd40582968f4a (patch)
treef032870cf59097cef1e5fd52e695abf8ebce9744 /container/init
parentd893a0e08fbf0ae7fc85b62a0814ab31d758169a (diff)
Support Custom Teardown
Similar to how we added an "RC" system to the init script, we now have a custom tear-down script (which can do things like unmount loop devices). Furthermore, we make sure that an `$XDG_RUNTIME_DIR/dbx` exists for things like SSH control sockets (so they can go somewhere where an application has R/W access to, while only keeping RO access to the configurations).
Diffstat (limited to 'container/init')
-rwxr-xr-xcontainer/init22
1 files changed, 14 insertions, 8 deletions
diff --git a/container/init b/container/init
index 49ee840..3f17b48 100755
--- a/container/init
+++ b/container/init
@@ -2,16 +2,22 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2026 Nicholas Rodrigues Lordello <[email protected]>
-if [ ! -f /run/.dbxenv ]; then
- echo "ERROR: not in a devbox" >&2
+if [ "$(id -u)" -ne 0 ]; then
+ printf '%s: operation not permitted\n' "$0" >&2
exit 1
fi
-for rc in /etc/dbx/rc.d/*; do
- if [ ! -f "$rc" ] || [ ! -x "$rc" ]; then
- continue
- fi
- "$rc" || printf '%s: %s failed (%d)\n' "$0" "$rc" "$?" >&2
-done
+touch /run/.dbxenv
+printf "%d\n" "$$" >/run/dbx.pid
+
+if [ -f /etc/dbx/init.local ] && [ -x /etc/dbx/init.local ]; then
+ /etc/dbx/init.local ||
+ printf '%s: init.local failed (%d)\n' "$0" "$?" >&2
+fi
+
+# The init process is not guaranteed to be on PID 1 for all runtimes (notably,
+# `krun` will wrap the init process). Tell tini to act like an init process
+# regardless of its PID.
+export TINI_SUBREAPER=yes
exec /usr/bin/tini /usr/sbin/sshd -- -D -e