]> git.pld-linux.org Git - packages/couchdb.git/blame - couchdb.init
- remove pid on stop
[packages/couchdb.git] / couchdb.init
CommitLineData
05085770
ER
1#!/bin/sh
2#
f4d2d59e
ER
3# couchdb Starts CouchDB
4# chkconfig: 2345 84 25
5# description: Apache CouchDB init script
6# pidfile: /var/run/couchdb.pid
05085770
ER
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
f4d2d59e 17COUCHDB="/usr/bin/couchdb"
05085770
ER
18COUCHDB_INI='/etc/apache-couchdb/couch.ini'
19COUCHDB_PID='/var/run/couchdb.pid'
20COUCHDB_USER='couchdb'
21COUCHDB_STDOUT='/dev/null'
22COUCHDB_STDERR='/dev/null'
23COUCHDB_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.
29if is_yes "${NETWORKING}"; then
30 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
f4d2d59e 31 msg_network_down "CouchDB"
05085770
ER
32 exit 1
33 fi
34else
35 exit 0
36fi
37
38start() {
39 # Check if the service is already running?
9c50fd5a 40 if [ -f /var/lock/subsys/couchdb ]; then
f4d2d59e 41 msg_already_running "CouchDB"
9c50fd5a 42 return
05085770 43 fi
9c50fd5a 44
f4d2d59e
ER
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 \
9c50fd5a
ER
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
57stop() {
9c50fd5a 58 if [ ! -f /var/lock/subsys/couchdb ]; then
f4d2d59e 59 msg_not_running "CouchDB"
9c50fd5a 60 return
05085770 61 fi
9c50fd5a
ER
62
63 # Stop daemons.
f4d2d59e 64 msg_stopping "CouchDB"
9c50fd5a 65 killproc --pidfile $COUCHDB_PID couchdb -TERM
18384d73 66 rm -f $COUCHDB_PID
9c50fd5a 67 rm -f /var/lock/subsys/couchdb
05085770
ER
68}
69
70reload() {
9c50fd5a 71 if [ ! -f /var/lock/subsys/couchdb ]; then
f4d2d59e 72 msg_not_running "CouchDB"
05085770 73 RETVAL=7
9c50fd5a 74 return
05085770 75 fi
9c50fd5a 76
f4d2d59e 77 msg_reloading "CouchDB"
9c50fd5a
ER
78 killproc --pidfile $COUCHDB_PID couchdb -HUP
79 RETVAL=$?
05085770
ER
80}
81
82condrestart() {
9c50fd5a 83 if [ ! -f /var/lock/subsys/couchdb ]; then
f4d2d59e 84 msg_not_running "CouchDB"
05085770 85 RETVAL=$1
9c50fd5a 86 return
05085770 87 fi
9c50fd5a
ER
88
89 stop
90 start
05085770
ER
91}
92
93RETVAL=0
94# See how we were called.
95case "$1" in
96 start)
97 start
98 ;;
99 stop)
100 stop
101 ;;
102 restart)
103 stop
104 start
105 ;;
106 try-restart)
107 condrestart 0
108 ;;
05085770
ER
109 reload|force-reload)
110 reload
111 ;;
05085770
ER
112 status)
113 status couchdb
114 RETVAL=$?
115 ;;
116 *)
117 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
118 exit 3
119esac
120
121exit $RETVAL
This page took 0.084439 seconds and 4 git commands to generate.