]> git.pld-linux.org Git - packages/couchdb.git/blob - couchdb.init
- show status
[packages/couchdb.git] / couchdb.init
1 #!/bin/sh
2 #
3 # couchdb       Apache CouchDB init script
4 # chkconfig:    2345 84 25
5 # description:  Apache CouchDB init script for the database server.
6 # pidfile:      /var/run/couchdb.pid
7 #
8 # $Id$
9
10 # Source function library
11 . /etc/rc.d/init.d/functions
12
13 # Get network config
14 . /etc/sysconfig/network
15
16 # Set defaults
17 COUCHDB="/usr/bin/couchdb"
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_TIMEOUT='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?
40         if [ -f /var/lock/subsys/couchdb ]; then
41                 msg_already_running "CouchDB"
42                 return
43         fi
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 $COUCHDB \
50                 -b -c "$COUCHDB_INI" -p "$COUCHDB_PID" \
51                 -o "$COUCHDB_STDOUT" -e "$COUCHDB_STDERR" \
52                 -r "$COUCHDB_RESPAWN_TIMEOUT" \
53                 $COUCHDB_OPTIONS
54         RETVAL=$?
55         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/couchdb
56 }
57
58 stop() {
59         if [ ! -f /var/lock/subsys/couchdb ]; then
60                 msg_not_running "CouchDB"
61                 return
62         fi
63
64         # Stop daemons.
65         msg_stopping "CouchDB"
66         su $COUCHDB_USER -c "$COUCHDB -d $COUCHDB_OPTIONS"
67         RETVAL=$?
68         if [ $RETVAL -eq 0 ]; then
69                 ok
70         else
71                 fail
72         fi
73
74         rm -f $COUCHDB_PID
75         rm -f /var/lock/subsys/couchdb
76 }
77
78 reload() {
79         if [ ! -f /var/lock/subsys/couchdb ]; then
80                 msg_not_running "CouchDB"
81                 RETVAL=7
82                 return
83         fi
84
85         msg_reloading "CouchDB"
86         killproc --pidfile $COUCHDB_PID couchdb -HUP
87         RETVAL=$?
88 }
89
90 condrestart() {
91         if [ ! -f /var/lock/subsys/couchdb ]; then
92                 msg_not_running "CouchDB"
93                 RETVAL=$1
94                 return
95         fi
96
97         stop
98         start
99 }
100
101 RETVAL=0
102 # See how we were called.
103 case "$1" in
104   start)
105         start
106         ;;
107   stop)
108         stop
109         ;;
110   restart)
111         stop
112         start
113         ;;
114   try-restart)
115         condrestart 0
116         ;;
117   reload|force-reload)
118         reload
119         ;;
120   status)
121     # Display the status of the running Apache CouchDB process.
122     $COUCHDB -s
123         status couchdb
124         RETVAL=$?
125         ;;
126   *)
127         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
128         exit 3
129 esac
130
131 exit $RETVAL
This page took 0.046506 seconds and 3 git commands to generate.