Just change the conditional script to use systemctl try-restart and hopefully it will do what we want.
This commit is contained in:
Kevin Fenzi 2018-02-20 00:24:11 +00:00
parent 3896b82982
commit e621c76c8f
2 changed files with 10 additions and 21 deletions

View file

@ -1,20 +1,9 @@
#!/bin/bash
# Restart SERVICE only if PACKAGE is installed.
# We use this throughout handlers/restart_services.yml
#
# We use this to try and restart a service.
# If it's not running, do nothing.
# If it is running, restart it.
#
SERVICE=$1
PACKAGE=$2
rpm -q $PACKAGE
INSTALLED=$?
if [ $INSTALLED -eq 0 ]; then
echo "Package $PACKAGE installed. Attempting restart of $SERVICE."
/sbin/service $SERVICE restart
exit $? # Exit with the /sbin/service status code
fi
# If the package wasn't installed, then pretend everything is fine.
echo "Package $PACKAGE not installed. Skipping restart of $SERVICE."
exit 0
/usr/bin/systemctl try-restart $1