Created
January 16, 2015 11:48
-
-
Save ahaeber/8ade1aa6d2ad0d07a047 to your computer and use it in GitHub Desktop.
CentOS compatible init.d script for python-bucky (EPEL)
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 | |
# bucky Init script for running the bucky daemon | |
# | |
# | |
# chkconfig: - 98 02 | |
# | |
# description: some description | |
# processname: bucky | |
PATH=/usr/bin:/sbin:/bin:/usr/sbin | |
export PATH | |
lockfile='/var/lock/subsys/bucky' | |
pidfile='/var/run/bucky.pid' | |
bucky='/usr/bin/bucky' | |
config='/etc/bucky/bucky.conf' | |
logfile='/var/log/bucky/bucky.log' | |
RETVAL=0 | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
# Determine if we can use the -p option to daemon, killproc, and status. | |
# RHEL < 5 can't. | |
if status | grep -q -- '-p' 2>/dev/null; then | |
pidopts="-p $pidfile" | |
fi | |
start() { | |
echo -n $"Starting bucky daemon: " | |
$bucky $config >> $logfile 2>&1 & | |
RETVAL=$? | |
local PID=`pgrep -f "${bucky} ${config}"` | |
echo $PID > ${pidfile} | |
[ $RETVAL -eq 0 ] && (touch ${lockfile}; echo_success) || echo_failure | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping bucky daemon: " | |
killproc $pidopts $bucky | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile} | |
} | |
restart() { | |
stop | |
start | |
} | |
rh_status() { | |
status $pidopts $bucky | |
RETVAL=$? | |
return $RETVAL | |
} | |
rh_status_q() { | |
rh_status >/dev/null 2>&1 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
condrestart|try-restart) | |
rh_status_q || exit 0 | |
restart | |
;; | |
status) | |
rh_status | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|condrestart|try-restart|status}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment