Skip to content

Instantly share code, notes, and snippets.

@benhaan
Created July 16, 2010 17:53
Show Gist options
  • Save benhaan/478676 to your computer and use it in GitHub Desktop.
Save benhaan/478676 to your computer and use it in GitHub Desktop.
#!/bin/bash
# init script for mongodb
# chkconfig: 2345 70 11
# description: mongod
# processname: mongod
# pidfile: /var/run/mongodb.pid
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
pidfile=/var/run/mongodb.pid
exec="/usr/local/bin/mongod"
prog="mongod"
lockfile="/var/lock/mongod"
daemon_ops="-f /etc/mongod.conf --fork --logappend"
start() {
if [ ! -x $exec ]
then
echo \$exec not found
exit 5
fi
echo -n $"Starting $prog: "
daemon $exec $daemon_ops
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile $pidfile
}
restart() {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo $"Usage: `basename $0` {start|stop|restart|status}"
exit 2
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment