Created
July 14, 2011 18:51
-
-
Save fredsmith/1083133 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 | |
# | |
# servicename Service Description | |
# | |
# chkconfig: 2345 62 38 | |
# description: Service Description | |
# | |
# the chkconfig: line is 'default runlevels' 'start priority' 'stop priority' | |
# Source function library | |
. /etc/init.d/functions | |
RETVAL=0 | |
start() { | |
echo -n $"Starting servicename: " | |
daemon --user username /path/to/server/daemon &> /dev/null | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/servicename | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping servicename: " | |
#if your service has a stop binary, call it here | |
#daemon --user username /path/to/stop/function | |
#otherwise: | |
killall servicename | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/datacloud | |
return $RETVAL | |
} | |
status() { | |
ps ax | grep servicename &> /dev/null | |
RETVAL=$? | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
restart | |
;; | |
condrestart) | |
[ -f /var/lock/subsys/servicename ] && restart || : | |
;; | |
reload) | |
reload | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" | |
exit 1 | |
esac | |
exit $? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment