]>
Commit | Line | Data |
---|---|---|
05085770 ER |
1 | #!/bin/sh |
2 | # | |
3 | # couchdb apache couchdb init script | |
4 | # | |
5 | # chkconfig: 345 85 25 | |
6 | # | |
7 | # description: apache couchdb init script | |
8 | # | |
9 | # $Id$ | |
10 | ||
11 | # Source function library | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
14 | # Get network config | |
15 | . /etc/sysconfig/network | |
16 | ||
17 | # Set defaults | |
18 | COUCHDB_INI='/etc/apache-couchdb/couch.ini' | |
19 | COUCHDB_PID='/var/run/couchdb.pid' | |
20 | COUCHDB_USER='couchdb' | |
21 | COUCHDB_STDOUT='/dev/null' | |
22 | COUCHDB_STDERR='/dev/null' | |
23 | COUCHDB_RESPAWN='5' | |
24 | ||
25 | # Get service config - may override defaults | |
26 | [ -f /etc/sysconfig/couchdb ] && . /etc/sysconfig/couchdb | |
27 | ||
28 | # Check that networking is up. | |
29 | if is_yes "${NETWORKING}"; then | |
30 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
31 | msg_network_down couchdb | |
32 | exit 1 | |
33 | fi | |
34 | else | |
35 | exit 0 | |
36 | fi | |
37 | ||
38 | start() { | |
39 | # Check if the service is already running? | |
9c50fd5a | 40 | if [ -f /var/lock/subsys/couchdb ]; then |
05085770 | 41 | msg_already_running couchdb |
9c50fd5a | 42 | return |
05085770 | 43 | fi |
9c50fd5a ER |
44 | |
45 | msg_starting couchdb | |
46 | test -n $COUCHDB_PID \ | |
47 | && touch $COUCHDB_PID \ | |
48 | && chown $COUCHDB_USER $COUCHDB_PID | |
49 | daemon --user $COUCHDB_USER /usr/bin/couchdb \ | |
50 | -b -c "$COUCHDB_INI" -p "$COUCHDB_PID" \ | |
51 | -o "$COUCHDB_STDOUT" -e "$COUCHDB_STDERR" \ | |
52 | -r "$COUCHDB_RESPAWN" | |
53 | RETVAL=$? | |
54 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/couchdb | |
05085770 ER |
55 | } |
56 | ||
57 | stop() { | |
9c50fd5a | 58 | if [ ! -f /var/lock/subsys/couchdb ]; then |
05085770 | 59 | msg_not_running couchdb |
9c50fd5a | 60 | return |
05085770 | 61 | fi |
9c50fd5a ER |
62 | |
63 | # Stop daemons. | |
64 | msg_stopping couchdb | |
65 | killproc couchdb | |
66 | killproc --pidfile $COUCHDB_PID couchdb -TERM | |
67 | rm -f /var/lock/subsys/couchdb | |
05085770 ER |
68 | } |
69 | ||
70 | reload() { | |
9c50fd5a | 71 | if [ ! -f /var/lock/subsys/couchdb ]; then |
05085770 ER |
72 | msg_not_running couchdb |
73 | RETVAL=7 | |
9c50fd5a | 74 | return |
05085770 | 75 | fi |
9c50fd5a ER |
76 | |
77 | msg_reloading couchdb | |
78 | killproc couchdb -HUP | |
79 | killproc --pidfile $COUCHDB_PID couchdb -HUP | |
80 | RETVAL=$? | |
05085770 ER |
81 | } |
82 | ||
83 | condrestart() { | |
9c50fd5a | 84 | if [ ! -f /var/lock/subsys/couchdb ]; then |
05085770 ER |
85 | msg_not_running couchdb |
86 | RETVAL=$1 | |
9c50fd5a | 87 | return |
05085770 | 88 | fi |
9c50fd5a ER |
89 | |
90 | stop | |
91 | start | |
05085770 ER |
92 | } |
93 | ||
94 | RETVAL=0 | |
95 | # See how we were called. | |
96 | case "$1" in | |
97 | start) | |
98 | start | |
99 | ;; | |
100 | stop) | |
101 | stop | |
102 | ;; | |
103 | restart) | |
104 | stop | |
105 | start | |
106 | ;; | |
107 | try-restart) | |
108 | condrestart 0 | |
109 | ;; | |
110 | # include force-reload here if program allows reloading without restart | |
111 | # otherwise remove reload action and support force-reload as restart if running | |
112 | reload|force-reload) | |
113 | reload | |
114 | ;; | |
115 | # use this one if program doesn't support reloading without restart | |
116 | force-reload) | |
117 | condrestart 7 | |
118 | ;; | |
119 | status) | |
120 | status couchdb | |
121 | RETVAL=$? | |
122 | ;; | |
123 | *) | |
124 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" | |
125 | exit 3 | |
126 | esac | |
127 | ||
128 | exit $RETVAL |