2011-03-06 04:22:57 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# /etc/rc.d/rc.mongo
|
|
|
|
#
|
|
|
|
# Start/stop/restart the mongodb server.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
PID=/var/state/mongodb.pid
|
|
|
|
LOG=/var/log/mongodb
|
|
|
|
DBPATH=/var/lib/mongodb
|
2014-07-05 02:58:12 +02:00
|
|
|
USER=mongo
|
|
|
|
GROUP=mongo
|
2011-03-06 04:22:57 +01:00
|
|
|
|
|
|
|
mongo_start() {
|
2014-07-05 02:58:12 +02:00
|
|
|
touch $LOG
|
|
|
|
chown $GROUP.$USER $LOG
|
|
|
|
touch $PID
|
|
|
|
chown $GROUP.$USER $PID
|
|
|
|
sudo -u $USER /usr/bin/mongod \
|
2011-03-06 04:22:57 +01:00
|
|
|
--dbpath=$DBPATH \
|
|
|
|
--fork \
|
|
|
|
--pidfilepath=$PID \
|
2014-07-05 02:58:12 +02:00
|
|
|
--logappend \
|
2011-03-06 04:22:57 +01:00
|
|
|
--logpath=$LOG \
|
|
|
|
--nohttpinterface
|
|
|
|
}
|
|
|
|
|
|
|
|
mongo_stop() {
|
|
|
|
kill `cat $PID`
|
2014-07-05 02:58:12 +02:00
|
|
|
# rm $PID
|
2011-03-06 04:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mongo_restart() {
|
|
|
|
mongo_stop
|
|
|
|
sleep 2
|
|
|
|
mongo_start
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
'start')
|
|
|
|
mongo_start
|
|
|
|
;;
|
|
|
|
'stop')
|
|
|
|
mongo_stop
|
|
|
|
;;
|
|
|
|
'restart')
|
|
|
|
mongo_restart
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Default is "start", for backwards compatibility with previous
|
|
|
|
# Slackware versions. This may change to a 'usage' error someday.
|
|
|
|
mongo_start
|
|
|
|
esac
|
|
|
|
|