]> git.pld-linux.org Git - packages/couchdb.git/blame - couchdb.init
- daemon --user dep
[packages/couchdb.git] / couchdb.init
CommitLineData
05085770
ER
1#!/bin/sh
2#
66579bcf 3# couchdb Apache CouchDB init script
f4d2d59e 4# chkconfig: 2345 84 25
66579bcf 5# description: Apache CouchDB init script for the database server.
f4d2d59e 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'
66579bcf 23COUCHDB_RESPAWN_TIMEOUT='5'
05085770
ER
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 \
66579bcf
ER
50 -b -c "$COUCHDB_INI" -p "$COUCHDB_PID" \
51 -o "$COUCHDB_STDOUT" -e "$COUCHDB_STDERR" \
52 -r "$COUCHDB_RESPAWN_TIMEOUT" \
53 $COUCHDB_OPTIONS
9c50fd5a
ER
54 RETVAL=$?
55 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/couchdb
05085770
ER
56}
57
58stop() {
9c50fd5a 59 if [ ! -f /var/lock/subsys/couchdb ]; then
f4d2d59e 60 msg_not_running "CouchDB"
9c50fd5a 61 return
05085770 62 fi
9c50fd5a
ER
63
64 # Stop daemons.
f4d2d59e 65 msg_stopping "CouchDB"
7d9853dd
ER
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
18384d73 74 rm -f $COUCHDB_PID
9c50fd5a 75 rm -f /var/lock/subsys/couchdb
05085770
ER
76}
77
78reload() {
9c50fd5a 79 if [ ! -f /var/lock/subsys/couchdb ]; then
f4d2d59e 80 msg_not_running "CouchDB"
05085770 81 RETVAL=7
9c50fd5a 82 return
05085770 83 fi
9c50fd5a 84
f4d2d59e 85 msg_reloading "CouchDB"
9c50fd5a
ER
86 killproc --pidfile $COUCHDB_PID couchdb -HUP
87 RETVAL=$?
05085770
ER
88}
89
90condrestart() {
9c50fd5a 91 if [ ! -f /var/lock/subsys/couchdb ]; then
f4d2d59e 92 msg_not_running "CouchDB"
05085770 93 RETVAL=$1
9c50fd5a 94 return
05085770 95 fi
9c50fd5a
ER
96
97 stop
98 start
05085770
ER
99}
100
101RETVAL=0
102# See how we were called.
103case "$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 ;;
05085770
ER
117 reload|force-reload)
118 reload
119 ;;
05085770
ER
120 status)
121 status couchdb
122 RETVAL=$?
123 ;;
124 *)
125 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
126 exit 3
127esac
128
129exit $RETVAL
This page took 0.094026 seconds and 4 git commands to generate.