mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
systemctl-wrapper.sh: Add script to check for systemd
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>
This commit is contained in:
parent
2e1115e722
commit
cecee8a842
1 changed files with 16 additions and 0 deletions
16
scripts/systemctl-wrapper.sh
Normal file
16
scripts/systemctl-wrapper.sh
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/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 "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue