7 # Required-Start: $syslog $local_fs $network
8 # Required-Stop: $syslog $local_fs $network
9 # Should-Start: $remote_fs
10 # Should-Stop: $remote_fs
11 # Default-Start: 3 4 5
12 # Default-Stop: 0 1 2 6
13 # Short-Description: MongoDB server
14 # Description: Starts and stops the MongoDB daemon
18 # Check for missing binaries (stale symlinks should not happen)
19 # Note: Special treatment of stop for LSB conformance
21 MONGOD_BIN="/usr/bin/mongod"
22 MONGOD_LOGFILE="/var/log/mongo/mongod.log"
23 MONGOD_PIDFILE="/var/run/mongod.pid"
24 MONGOD_CONFIG="/etc/sysconfig/mongod"
29 test -x $MONGOD_BIN || { echo "$MONGOD_BIN not installed";
30 if [ "$1" = "stop" ]; then exit 0;
33 # Check for existence of needed config file and read it
34 # test -r $MONGOD_CONFIG || { echo "$MONGOD_CONFIG not existing";
35 # if [ "$1" = "stop" ]; then exit 0;
41 [ -e $MONGOD_CONFIG ] && . $MONGOD_CONFIG
44 # Source LSB init functions
45 # providing start_daemon, killproc, pidofproc,
46 # log_success_msg, log_failure_msg and log_warning_msg.
47 # This is currently not used by UnitedLinux based distributions and
48 # not needed for init scripts for UnitedLinux only. If it is used,
49 # the functions from rc.status should not be sourced or used.
50 #. /lib/lsb/init-functions
52 # Shell functions sourced from /etc/rc.status:
53 # rc_check check and set local and overall rc status
54 # rc_status check and set local and overall rc status
55 # rc_status -v be verbose in local rc status and clear it afterwards
56 # rc_status -v -r ditto and clear both the local and overall rc status
57 # rc_status -s display "skipped" and exit with status 3
58 # rc_status -u display "unused" and exit with status 3
59 # rc_failed set local and overall rc status to failed
60 # rc_failed <num> set local and overall rc status to <num>
61 # rc_reset clear both the local and overall rc status
62 # rc_exit exit appropriate to overall rc status
63 # rc_active checks whether a service is activated by symlinks
66 # Reset status of this service
69 # Return values acc. to LSB for all commands but status:
71 # 1 - generic or unspecified error
72 # 2 - invalid or excess argument(s)
73 # 3 - unimplemented feature (e.g. "reload")
74 # 4 - user had insufficient privileges
75 # 5 - program is not installed
76 # 6 - program is not configured
77 # 7 - program is not running
78 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
80 # Note that starting an already running service, stopping
81 # or restarting a not-running service as well as the restart
82 # with force-reload (in case signaling is not supported) are
83 # considered a success.
91 echo -n "Starting service MongoDB "
92 ## Start daemon with startproc(8). If this fails
93 ## the return value is set appropriately by startproc.
94 /sbin/startproc -u $MONGOD_USER -g $MONGOD_GROUP -s -e $MONGOD_BIN --config /etc/mongod.conf run
95 # Remember status and be verbose
99 echo -n "Stopping service MongoDB "
100 # killproc -p /var/lib/mongo/mongod.lock -t30 -TERM /usr/bin/mongod
101 /sbin/killproc -TERM $MONGOD_BIN
104 try-restart|condrestart)
105 ## Do a restart only if the service was active before.
106 ## Note: try-restart is now part of LSB (as of 1.9).
107 ## RH has a similar command named condrestart.
108 if test "$1" = "condrestart"; then
109 echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
115 rc_reset # Not running is not a failure.
117 # Remember status and be quiet
121 ## Stop the service and regardless of whether it was
122 ## running or not, start it again.
126 # Remember status and be quiet
133 echo -n "Checking for service MongoDB: "
134 /sbin/checkproc -p $MONGOD_PIDFILE $MONGOD_BIN
138 echo "Usage: $0 {start|stop|status|try-restart|restart|reload}"