Created
July 23, 2019 19:37
-
-
Save hadihammurabi/f7d0a82243761fbaa5b2f42c22c1c3fe to your computer and use it in GitHub Desktop.
OpenRC init file for MongoDB
This file contains hidden or 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
#!/usr/bin/openrc-run | |
# MONGOHOME="/usr/local/mongodb" | |
CONFIGFILE="/etc/mongodb.conf" | |
DBPATH=`awk -F= '/^dbpath[ ]*=/{print $2}' "$CONFIGFILE" |sed -e 's/^[ ]*//'` | |
COMMAND="mongod" | |
OPT="--config $CONFIGFILE" | |
mongod=$COMMAND | |
PIDPATH="/var/run/mongodb/mongodb.pid" | |
usage() { | |
echo "Usage: /etc/init.d/mongodb {start|stop|restart|status}" | |
exit 0 | |
} | |
if [ $# != 1 ]; then | |
usage | |
fi | |
start() | |
{ | |
echo -n $"Starting mongod..." | |
start-stop-daemon -p $PIDPATH -b -m -S $COMMAND -- $OPT | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod | |
} | |
stop() { | |
echo -n $"Stopping mongod..." | |
killall $COMMAND | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment