Created
July 11, 2011 08:28
-
-
Save xlson/1075481 to your computer and use it in GitHub Desktop.
Simple service script for Graphites carbon-cache daemon
This file contains hidden or 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 | |
# | |
# chkconfig: 35 90 12 | |
# description: carbon-cache script | |
# | |
LOCKFILE=/var/lock/subsys/carbon | |
# Get function from functions library | |
. /etc/init.d/functions | |
# Start the service carbon-cache | |
start() { | |
cd /opt/graphite && ./bin/carbon-cache.py start | |
### Create the lock file ### | |
touch $LOCKFILE | |
success $"carbon-cache.py startup" | |
echo "carbon-cache started" | |
} | |
# Stop the service carbon-cache.py | |
stop() { | |
cd /opt/graphite && ./bin/carbon-cache.py stop | |
### Now, delete the lock file ### | |
rm -f $LOCKFILE | |
success $"carbon-cache.py stopped" | |
echo "carbon-cache stopped" | |
} | |
### main logic ### | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status carbon-cache.py | |
;; | |
restart|reload|condrestart) | |
stop | |
start | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|reload|status}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be really happy about any hints about how to make this script better as I'm not that good with bash.