mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
Maintainer scripts often mess with systemd services via systemctl. In Docker containers, chroot environments or other environments not governed by Systemd, systemctl will not exist or complain. This is a frequent use case, worthy of providing a wrapper to catch and ignore these cases conveniently. Signed-off-by: Jan Lindemann <jan@janware.com>
16 lines
363 B
Bash
16 lines
363 B
Bash
#!/bin/bash
|
|
|
|
reason=""
|
|
systemctl="/usr/bin/systemctl"
|
|
|
|
[ "$(ps -p 1 -o comm=)" = "systemd" ] || reason="Trying to run $exe in an environment not controlled by Systemd"
|
|
[ -x $systemctl ] || reason="Can't run $exe."
|
|
if [ "$reason" ]; then
|
|
title="$reason. Ignoring."
|
|
echo ",-- $title -- >"
|
|
echo "| $0 $@"
|
|
echo "\`-- $title -- <"
|
|
exit 0
|
|
fi
|
|
|
|
exec $systemctl "$@"
|