]> git.pld-linux.org Git - packages/mongodb.git/blame - mongodb.init
EA based on v8 (excludes x32)
[packages/mongodb.git] / mongodb.init
CommitLineData
69fbae1d 1#!/bin/sh
2#
138b8a64 3# mongod mongod
4#
5# chkconfig: 345 60 40
6#
1a2080c0 7# description: mongod is a NoSQL database daemon.
138b8a64 8#
9# processname: mongod
10# pidfile: /var/run/mongod.pid
69fbae1d 11#
ab177c48
ER
12### BEGIN INIT INFO
13# Provides: mongod
14# Required-Start: $syslog $local_fs $network
15# Required-Stop: $syslog $local_fs $network
16# Should-Start: $remote_fs
17# Should-Stop: $remote_fs
18# Default-Start: 3 4 5
19# Default-Stop: 0 1 2 6
20# Short-Description: MongoDB server
21# Description: Starts and stops the MongoDB daemon
22### END INIT INFO
69fbae1d 23
138b8a64 24# Source function library
25. /etc/rc.d/init.d/functions
69fbae1d 26
138b8a64 27# Get network config
28. /etc/sysconfig/network
69fbae1d 29
e5fd6426
ER
30# Check that networking is up.
31if is_yes "${NETWORKING}"; then
32 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
33 msg_network_down "mongod"
34 exit 1
35 fi
36else
37 exit 0
38fi
39
69fbae1d 40MONGOD_BIN="/usr/bin/mongod"
69fbae1d 41MONGOD_PIDFILE="/var/run/mongod.pid"
42MONGOD_CONFIG="/etc/sysconfig/mongod"
43
44MONGOD_USER=mongod
45MONGOD_GROUP=mongod
46
138b8a64 47# Get service config
48[ -f /etc/sysconfig/mongod ] && . /etc/sysconfig/mongod
69fbae1d 49
138b8a64 50start() {
51 # Check if the service is already running?
52 if [ -f /var/lock/subsys/mongod ]; then
53 msg_already_running "mongod"
54 return
55 fi
69fbae1d 56
1a2080c0
JK
57 started=0
58 for config in /etc/mongod/*.conf ; do
59 instance=$(basename "$config" .conf)
60 msg_starting "mongod '$instance' instance"
61 if [ "$instance" = "default" ] ; then
62 pidfile="$MONGOD_PIDFILE"
63 else
64 pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
65 fi
66 daemon --pidfile "$pidfile" --user $MONGOD_USER \
cf68c7a9 67 $MONGOD_BIN --config "$config" --fork
1a2080c0
JK
68 [ $? -eq 0 ] && started=$(($started + 1))
69 done
70 # at least one started - the service is running
71 [ $started -eq 0 ] && RETVAL=1
138b8a64 72 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
73}
69fbae1d 74
138b8a64 75stop() {
76 if [ ! -f /var/lock/subsys/mongod ]; then
77 msg_not_running "mongod"
78 return
79 fi
69fbae1d 80
1a2080c0
JK
81 for config in /etc/mongod/*.conf ; do
82 instance=$(basename "$config" .conf)
83 msg_stopping "mongod '$instance' instance"
84 if [ "$instance" = "default" ] ; then
85 pidfile="$MONGOD_PIDFILE"
86 else
87 pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
88 fi
89 killproc --pidfile "$pidfile" mongod
90 done
138b8a64 91 rm -f /var/lock/subsys/mongod >/dev/null 2>&1
92}
69fbae1d 93
138b8a64 94condrestart() {
95 if [ ! -f /var/lock/subsys/mongod ]; then
96 msg_not_running "mongod"
97 RETVAL=$1
98 return
99 fi
69fbae1d 100
138b8a64 101 stop
102 start
103}
69fbae1d 104
138b8a64 105reload() {
106 if [ ! -f /var/lock/subsys/mongod ]; then
107 msg_not_running "mongod"
108 RETVAL=7
109 return
110 fi
69fbae1d 111
1a2080c0
JK
112 for config in /etc/mongod/*.conf ; do
113 instance=$(basename "$config" .conf)
114 msg_reloading "mongod '$instance' instance"
115 if [ "$instance" = "default" ] ; then
116 pidfile="$MONGOD_PIDFILE"
117 else
118 pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
119 fi
120 killproc --pidfile "$pidfile" mongod -HUP
121 done
138b8a64 122}
69fbae1d 123
138b8a64 124RETVAL=0
125# See how we were called.
69fbae1d 126case "$1" in
138b8a64 127 start)
128 start
129 ;;
130 stop)
131 stop
132 ;;
133 restart)
134 stop
135 start
136 ;;
137 try-restart)
138 condrestart 0
139 ;;
140 reload|force-reload)
141 reload
142 ;;
143 status)
144 status mongod
145 exit $?
146 ;;
147 *)
148 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
149 exit 3
69fbae1d 150esac
138b8a64 151
152exit $RETVAL
This page took 0.080925 seconds and 4 git commands to generate.