summaryrefslogtreecommitdiffstats
path: root/mongodb/build/rc.mongodb
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2021-03-02 20:58:13 +0000
committer Eric Hameleers <alien@slackware.com>2021-03-02 20:58:13 +0000
commit66eeb1a7afdad50be2ffa13393fe000a00b81e2e (patch)
treef83acb04693768848803a945b084bd346845c913 /mongodb/build/rc.mongodb
parenta61bac2741b784c06ba124b1db07436daaf24b73 (diff)
downloadasb-66eeb1a7afdad50be2ffa13393fe000a00b81e2e.tar.gz
asb-66eeb1a7afdad50be2ffa13393fe000a00b81e2e.tar.xz
Initial revision
Diffstat (limited to 'mongodb/build/rc.mongodb')
-rw-r--r--mongodb/build/rc.mongodb75
1 files changed, 75 insertions, 0 deletions
diff --git a/mongodb/build/rc.mongodb b/mongodb/build/rc.mongodb
new file mode 100644
index 00000000..1c131aa8
--- /dev/null
+++ b/mongodb/build/rc.mongodb
@@ -0,0 +1,75 @@
+#!/bin/sh
+# ---------------------------------------------------------------------------
+# Slackware init script for MongoDB:
+# /etc/rc.d/rc.mongodb
+# ---------------------------------------------------------------------------
+
+USR="mongo"
+GRP="mongo"
+
+DBPATH="/var/lib/mongodb"
+LOGFILE="/var/log/mongodb/mongodb"
+PID="/var/state/mongodb.pid"
+SHELL="/bin/bash"
+
+mongo_start() {
+ touch $LOGFILE
+ chown $USR:$GRP $LOGFILE
+ touch $PID
+ chown $USR:$GRP $PID
+
+ su -l $USR -s $SHELL -c "/usr/bin/mongod --fork \
+ --dbpath=$DBPATH \
+ --pidfilepath=$PID \
+ --logpath=$LOGFILE --logappend"
+ if [ $? -eq 0 ]; then
+ echo "MongoDB server started successfully."
+ else
+ echo "MongoDB server failed to start, exiting now..."
+ exit 1
+ fi
+}
+
+mongo_stop() {
+ kill -TERM $(cat $PID)
+ if [ $? -eq 0 ]; then
+ echo "MongoDB server stopped successfully."
+ rm -f $PID
+ else
+ echo "MongoDB server shutdown failed!"
+ exit 1
+ fi
+}
+
+mongo_restart() {
+ mongo_stop
+ sleep 5
+ mongo_start
+}
+
+mongo_status() {
+ PIDS=$(pidof mongod)
+ if [ "x$PIDS" = "x" ]; then
+ echo "MongoDB is not running!"
+ else
+ echo "MongoDB is running at pid(s) ${PIDS}."
+ fi
+}
+
+case "$1" in
+ start)
+ mongo_start
+ ;;
+ stop)
+ mongo_stop
+ ;;
+ restart)
+ mongo_restart
+ ;;
+ status)
+ mongo_status
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|status}"
+ ;;
+esac