Created
November 2, 2017 00:01
-
-
Save jbovet/77274a70336253e4c60488307919f459 to your computer and use it in GitHub Desktop.
Slackware mongoldb 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/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