Created
September 13, 2012 07:56
-
-
Save GarPit/3712734 to your computer and use it in GitHub Desktop.
MongoDB init script
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 | |
# | |
# mongodb Startup script for the mongodb server | |
# | |
# chkconfig: - 64 36 | |
# description: MongoDB Database Server | |
# | |
# processname: mongodb | |
# | |
# Source function library | |
. /etc/rc.d/init.d/functions | |
if [ -f /etc/sysconfig/mongodb ]; then | |
. /etc/sysconfig/mongodb | |
fi | |
prog="mongod" | |
mongod="/usr/local/mongodb/bin/mongod" | |
RETVAL=0 | |
start() { | |
echo -n $"Starting $prog: " | |
daemon $mongod "--fork --logpath /var/log/mongodb.log --logappend 2>&1 >>/var/log/mongodb.log" | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc $prog | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog | |
return $RETVAL | |
} | |
reload() { | |
echo -n $"Reloading $prog: " | |
killproc $prog -HUP | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
condrestart) | |
if [ -f /var/lock/subsys/$prog ]; then | |
stop | |
start | |
fi | |
;; | |
reload) | |
reload | |
;; | |
status) | |
status $mongod | |
RETVAL=$? | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" | |
RETVAL=1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment