]> git.pld-linux.org Git - packages/couchdb.git/blob - couchdb.init
- unify
[packages/couchdb.git] / couchdb.init
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?
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 /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
55 }
56
57 stop() {
58         if [ ! -f /var/lock/subsys/couchdb ]; then
59                 msg_not_running couchdb
60                 return
61         fi
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
68 }
69
70 reload() {
71         if [ ! -f /var/lock/subsys/couchdb ]; then
72                 msg_not_running couchdb
73                 RETVAL=7
74                 return
75         fi
76
77         msg_reloading couchdb
78         killproc couchdb -HUP
79         killproc --pidfile $COUCHDB_PID couchdb -HUP
80         RETVAL=$?
81 }
82
83 condrestart() {
84         if [ ! -f /var/lock/subsys/couchdb ]; then
85                 msg_not_running couchdb
86                 RETVAL=$1
87                 return
88         fi
89
90         stop
91         start
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
This page took 0.095511 seconds and 3 git commands to generate.