test-lab/probes/toolbox-systemd-hook.sh

31 lines
1.3 KiB
Bash

#!/bin/sh
# Private adapter probe for Arch Toolbx 0.3; not a host hook or stable API.
set -eu
test -f /run/.toolboxenv && test -f /run/.containerenv || {
echo 'This adapter requires a Toolbx container' >&2
exit 1
}
op=${1:?Missing action}
shift
case "$op" in
daemon-reload-system|daemon-reload-user|enqueue-marked|reload|restart|binfmt|sysctl|udev-reload)
# Toolbx shares host runtime mounts but has no system manager of its own.
printf 'Toolbx: %s belongs to the host runtime; skipped in container\n' "$op"
;;
tmpfiles)
# Keep container-local state creation. Exclude the reviewed upstream
# shared mounts and their /home and /mnt aliases; no blanket error ignore.
exec /usr/bin/systemd-tmpfiles --create -E \
--exclude-prefix=/tmp --exclude-prefix=/home --exclude-prefix=/var/home \
--exclude-prefix=/mnt --exclude-prefix=/var/mnt --exclude-prefix=/media \
--exclude-prefix=/var/lib/flatpak \
--exclude-prefix=/var/lib/systemd/coredump --exclude-prefix=/var/log/journal
;;
catalog|hwdb|sysusers|update)
exec /usr/share/libalpm/scripts/systemd-hook "$op" "$@"
;;
*)
printf 'Unreviewed Toolbx systemd hook action: %s\n' "$op" >&2
exit 1
;;
esac