Created
June 29, 2018 16:33
-
-
Save dumbda/9019de13a4e20df67a3cf9949bc785ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Init script for foreman smart proxy | |
# | |
# chkconfig: - 85 15 | |
# description: Init script for foreman proxy | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
if [ -f /etc/sysconfig/foreman-proxy ]; then | |
. /etc/sysconfig/foreman-proxy | |
fi | |
prog=foreman-proxy | |
RETVAL=0 | |
FOREMAN_PROXY_PID=/var/run/$prog/$prog.pid | |
FOREMAN_PROXY_USER=${FOREMAN_PROXY_USER:-foreman-proxy} | |
FOREMAN_PROXY_HOME=${FOREMAN_PROXY_HOME:-/usr/share/foreman-proxy} | |
FOREMAN_PROXY_SETTINGS=${FOREMAN_PROXY_SETTINGS:-/etc/foreman-proxy/settings.yml} | |
start() { | |
echo -n $"Starting $prog: " | |
if egrep -q ':daemon:\s*false' $FOREMAN_PROXY_SETTINGS; then | |
echo -n $":daemon is false in settings.yml" | |
failure $":daemon is false in settings.yml" | |
echo | |
return 6 | |
fi | |
daemon --user ${FOREMAN_PROXY_USER} ${FOREMAN_PROXY_HOME}/bin/smart-proxy > /dev/null | |
RETVAL=$? | |
if [ $RETVAL = 0 ] | |
then | |
echo_success | |
else | |
echo_failure | |
fi | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
if [ -f ${FOREMAN_PROXY_PID} ]; then | |
killproc -p ${FOREMAN_PROXY_PID} | |
RETVAL=$? | |
else | |
echo -n $"$prog was not running."; | |
failure $"$prog was not running."; | |
echo | |
return 1 | |
fi | |
echo | |
[ $RETVAL -eq 0 ] && rm -f ${FOREMAN_PROXY_PID} | |
return $RETVAL | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
echo -n "$prog" | |
status -p $FOREMAN_PROXY_PID | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
condrestart) | |
stop | |
[ $? -eq 0 ] && start | |
;; | |
*) | |
echo $"Usage: $prog {start|stop|restart|condrestart}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment