]>
Commit | Line | Data |
---|---|---|
69fbae1d | 1 | #!/bin/sh |
2 | # | |
138b8a64 | 3 | # mongod mongod |
4 | # | |
5 | # chkconfig: 345 60 40 | |
6 | # | |
7 | # description: mongod is a cache daemon. | |
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. |
31 | if 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 | |
36 | else | |
37 | exit 0 | |
38 | fi | |
39 | ||
69fbae1d | 40 | MONGOD_BIN="/usr/bin/mongod" |
41 | MONGOD_LOGFILE="/var/log/mongo/mongod.log" | |
42 | MONGOD_PIDFILE="/var/run/mongod.pid" | |
43 | MONGOD_CONFIG="/etc/sysconfig/mongod" | |
44 | ||
45 | MONGOD_USER=mongod | |
46 | MONGOD_GROUP=mongod | |
47 | ||
138b8a64 | 48 | # Get service config |
49 | [ -f /etc/sysconfig/mongod ] && . /etc/sysconfig/mongod | |
69fbae1d | 50 | |
138b8a64 | 51 | start() { |
52 | # Check if the service is already running? | |
53 | if [ -f /var/lock/subsys/mongod ]; then | |
54 | msg_already_running "mongod" | |
55 | return | |
56 | fi | |
69fbae1d | 57 | |
c93cbd66 ER |
58 | msg_starting "mongod" |
59 | daemon --pidfile $MONGOD_PIDFILE --user $MONGOD_USER \ | |
60 | $MONGOD_BIN --config /etc/mongod.conf run | |
61 | ret=$? | |
62 | [ $ret = 0 ] || RETVAL=$? | |
138b8a64 | 63 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod |
64 | } | |
69fbae1d | 65 | |
138b8a64 | 66 | stop() { |
67 | if [ ! -f /var/lock/subsys/mongod ]; then | |
68 | msg_not_running "mongod" | |
69 | return | |
70 | fi | |
69fbae1d | 71 | |
c93cbd66 ER |
72 | msg_stopping "mongod" |
73 | killproc --pidfile $MONGOD_PIDFILE mongod | |
138b8a64 | 74 | rm -f /var/lock/subsys/mongod >/dev/null 2>&1 |
75 | } | |
69fbae1d | 76 | |
138b8a64 | 77 | condrestart() { |
78 | if [ ! -f /var/lock/subsys/mongod ]; then | |
79 | msg_not_running "mongod" | |
80 | RETVAL=$1 | |
81 | return | |
82 | fi | |
69fbae1d | 83 | |
138b8a64 | 84 | stop |
85 | start | |
86 | } | |
69fbae1d | 87 | |
138b8a64 | 88 | reload() { |
89 | if [ ! -f /var/lock/subsys/mongod ]; then | |
90 | msg_not_running "mongod" | |
91 | RETVAL=7 | |
92 | return | |
93 | fi | |
69fbae1d | 94 | |
c93cbd66 ER |
95 | msg_reloading "mongod" |
96 | killproc --pidfile $MONGOD_PIDFILE mongod -HUP | |
138b8a64 | 97 | } |
69fbae1d | 98 | |
138b8a64 | 99 | RETVAL=0 |
100 | # See how we were called. | |
69fbae1d | 101 | case "$1" in |
138b8a64 | 102 | start) |
103 | start | |
104 | ;; | |
105 | stop) | |
106 | stop | |
107 | ;; | |
108 | restart) | |
109 | stop | |
110 | start | |
111 | ;; | |
112 | try-restart) | |
113 | condrestart 0 | |
114 | ;; | |
115 | reload|force-reload) | |
116 | reload | |
117 | ;; | |
118 | status) | |
119 | status mongod | |
120 | exit $? | |
121 | ;; | |
122 | *) | |
123 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" | |
124 | exit 3 | |
69fbae1d | 125 | esac |
138b8a64 | 126 | |
127 | exit $RETVAL |