check_systemd_service: make sure the service exists
This commit is contained in:
parent
36fb1e26c4
commit
1e2062fc6a
|
@ -41,6 +41,12 @@ if [ -z "$UNIT_NAME" ]; then
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if the unit exists
|
||||||
|
if ! systemctl list-units --full -all | grep -Fq "\b$UNIT_NAME.service\b"; then
|
||||||
|
echo "CRITICAL - $UNIT_NAME does not exist"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if the unit is enabled
|
# Check if the unit is enabled
|
||||||
enabled=$(systemctl is-enabled "$UNIT_NAME")
|
enabled=$(systemctl is-enabled "$UNIT_NAME")
|
||||||
if [ "$enabled" != "enabled" ] && [ "$IS_ALLOWED_DISABLED" = false ]; then
|
if [ "$enabled" != "enabled" ] && [ "$IS_ALLOWED_DISABLED" = false ]; then
|
||||||
|
|
Loading…
Reference in New Issue