Instantly share code, notes, and snippets.

Embed
What would you like to do?
Slackware mongoldb script
#!/bin/sh
#
# MongoDB daemon control script.
# Written for Slackware Linux by Jose Bovet Derpich <jose.bovet@gmail.com>.
BIN=/opt/mongodb/bin/mongod
PID=/var/run/mongod.pid
LOG=/var/log/mongodb
DBPATH=/opt/mongodb/data/db
mongod_start() {
if [ -s $PID ]; then
echo "mongod appears to already be running?"
exit 1
fi
echo "Starting mongo server daemon..."
if [ -x $BIN ]; then
$BIN --auth --dbpath=$DBPATH --pidfilepath=$PID --logpath=$LOG --fork --bind_ip 127.0.0.1
fi
}
mongod_stop() {
echo "Shutdown mongod..."
if [ -r $PID ]; then
kill -TERM $(cat $PID)
rm $PID
fi
}
mongod_restart() {
mongod_stop
sleep 3
mongod_start
}
case "$1" in
start)
mongod_start
;;
stop)
mongod_stop
;;
restart)
mongod_restart
;;
*)
echo "usage: `basename $0` {start|stop|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment