diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-09-15 14:05:52 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-09-15 14:05:52 +0200 |
| commit | 717968007c67fca3067777cffa3dd40582968f4a (patch) | |
| tree | f032870cf59097cef1e5fd52e695abf8ebce9744 /container/stop | |
| parent | d893a0e08fbf0ae7fc85b62a0814ab31d758169a (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/stop')
| -rwxr-xr-x | container/stop | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/container/stop b/container/stop new file mode 100755 index 0000000..9affb9c --- /dev/null +++ b/container/stop @@ -0,0 +1,20 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2026 Nicholas Rodrigues Lordello <[email protected]> + +if [ "$(id -u)" -ne 0 ]; then + printf '%s: operation not permitted\n' "$0" >&2 + exit 1 +fi + +if [ -x /etc/dbx/stop.local ]; then + /etc/dbx/stop.local || + printf '%s: stop.local failed (%d)\n' "$0" "$?" >&2 +fi + +if ! pid="$(cat /run/dbx.pid)"; then + printf '%s: could not read init PID file, assuming 1\n' "$0" >&2 + pid=1 +fi +kill -TERM "$pid" || + printf '%s: could not stop init[%s] (%d)\n' "$0" "$pid" "$?" >&2 |
