Try out this conditional restart stuff.

This commit is contained in:
Ralph Bean 2014-03-14 15:30:32 +00:00
parent 38126d44e5
commit fb6ee8bd49
4 changed files with 52 additions and 5 deletions

View file

@ -0,0 +1,20 @@
#!/bin/bash
# Restart SERVICE only if PACKAGE is installed.
# We use this throughout handlers/restart_services.yml
SERVICE=$1
PACKAGE=$2
/usr/bin/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