Created
March 9, 2010 15:41
-
-
Save adamhunter/326708 to your computer and use it in GitHub Desktop.
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 | |
| # | |
| # Init file for Riak | |
| # Supports start, stop, restart and status | |
| # chkconfig: 345 96 30 | |
| # description: Riak | |
| # Source function library. | |
| #. /etc/init.d/functions | |
| BASE_DIR="/home/riak/current" | |
| RUN_SCRIPT="${BASE_DIR}/bin/riak" | |
| LOCK_FILE="${BASE_DIR}/riak.lock" | |
| RETVAL=0 | |
| prog="riak" | |
| start() | |
| { | |
| echo $"Starting $prog " | |
| /bin/su riak -c "${RUN_SCRIPT} start" | |
| } | |
| stop() | |
| { | |
| echo $"Stopping $prog " | |
| /bin/su riak -c "${RUN_SCRIPT} stop" | |
| } | |
| status() | |
| { | |
| if [ ! -f ${LOCK_FILE} ]; then | |
| echo $"Riak is stopped." | |
| return 1 | |
| fi | |
| if [ -f ${LOCK_FILE} ]; then | |
| echo $"Riak is running." | |
| return 1 | |
| fi | |
| } | |
| case "$1" in | |
| start) | |
| start | |
| [ $RETVAL -eq 0 ] && touch ${LOCK_FILE} | |
| ;; | |
| stop) | |
| stop | |
| [ $RETVAL -eq 0 ] && rm -f ${LOCK_FILE} | |
| ;; | |
| status) | |
| status | |
| ;; | |
| restart) | |
| stop | |
| start | |
| ;; | |
| *) | |
| echo $"Usage: $0 {start|stop|status|restart}" | |
| RETVAL=1 | |
| esac | |
| exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment