Files
fedora-infra_ansible/roles/base/files/common-scripts/proxy-conditional-reload.sh
2023-05-19 23:24:18 +02:00

26 lines
701 B
Bash

#!/bin/bash
# reload SERVICE only if PACKAGE is installed.
# We use this throughout handlers/restart_services.yml
HOST=$(hostname -s)
SERVICE=$1
PACKAGE=$2
rpm -q $PACKAGE
INSTALLED=$?
if [[ ! -f "/etc/httpd/ticketkey_*.tkey" && "$HOST" =~ "^proxy" ]]; then
# This host is not configured yet and not proxy host, do not try and restart httpd
exit 0
fi
if [ $INSTALLED -eq 0 ]; then
echo "Package $PACKAGE installed. Attempting reload of $SERVICE."
/sbin/service $SERVICE reload
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 reload of $SERVICE."
exit 0