__systemd_unit: fix crash when transitioning to state=absent

This type tried to disable an unit after it has removed it, which
failed. Now the removal happens in gencode-remote, after the unit has
been stopped and disabled.
This commit is contained in:
Adam Dej 2018-07-11 15:58:41 +02:00
parent 8d84834db6
commit 37b37f6e66
2 changed files with 5 additions and 1 deletions

View file

@ -25,6 +25,8 @@ current_enablement_state=$(cat "${__object}/explorer/enablement-state")
if [ "${state}" = "absent" ]; then
if [ ! -z "${current_enablement_state}" ]; then
echo "systemctl --now disable ${name}"
echo "rm -f /etc/systemd/system/${name}"
echo "systemctl daemon-reload"
fi
exit 0

View file

@ -30,7 +30,9 @@ name="${__object_id}"
source=$(cat "${__object}/parameter/source")
state=$(cat "${__object}/parameter/state")
if [ -z "${source}" ] && [ "${state}" != "absent" ]; then
# The unit must be disabled before removing its unit file. The unit file is
# therefore removed by gencode-remote of this type, not here.
if [ -z "${source}" ] || [ "${state}" = "absent" ]; then
exit 0
fi