Tobias Brunner 6b8b67be81 testing: Fix systemctl wrapper and adapt enabling services on winnetou
The wrapper called the command twice for any unit but "strongswan" and
it didn't return the correct exit code.  This was noticed when an
if-updown script tried to check if systemd-resolved is active and always
succeeded, which caused failing attempts to configure it.

But now that the return code is correct, trying to enable bind9 won't
fail silently anymore if the unit doesn't exist (similar on older systems
for named), so this is adapted.
2023-07-13 10:48:53 +02:00

26 lines
602 B
Bash
Executable File

#!/bin/bash
#
# LEAK_DETECTIVE_LOG is set for automated runs, however, this is not passed
# to a process started via systemctl. This wrapper is used to set the variable
# for the strongswan.service unit.
ORIG=/bin/systemctl
CONF=/lib/systemd/system/strongswan.service
if [[ "$2" != "strongswan" ]]; then
exec $ORIG "$@"
fi
if [[ "$1" == "start" && -n $LEAK_DETECTIVE_LOG ]]; then
sed -i "s:Type=:Environment=LEAK_DETECTIVE_LOG=$LEAK_DETECTIVE_LOG\nType=:" $CONF 2>/dev/null
fi
$ORIG "$@"
STATUS=$?
if [[ "$1" == "stop" ]]; then
sed -i '/LEAK_DETECTIVE_LOG/d' $CONF 2>/dev/null
fi
exit $STATUS