Skip to content

Instantly share code, notes, and snippets.

@cs3b
Created February 4, 2010 09:58
Show Gist options
  • Save cs3b/294494 to your computer and use it in GitHub Desktop.
Save cs3b/294494 to your computer and use it in GitHub Desktop.
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/mongo/bin/mongod
PIDFILE=/var/run/mongodb/mongodb.pid
LOGFILE=/var/log/mongodb/mongod.log
DATAPATH=/var/data/mongodb
NAME=mongodb
test -x $DAEMON || exit 0
#set -e
case "$1" in
start)
echo -n "Starting $NAME: "
start-stop-daemon --pidfile $PIDFILE --exec $DAEMON --start -- --fork --dbpath $DATAPATH --logpath $LOGFILE --logappend run
echo "ok"
;;
stop)
echo -n "Stopping $NAME: "
start-stop-daemon --quiet --pidfile $PIFDILE --exec $DAEMON --stop
echo "ok"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment