]> git.pld-linux.org Git - packages/couchdb.git/blame_incremental - couchdb.init
- add tmpfiles.d
[packages/couchdb.git] / couchdb.init
... / ...
CommitLineData
1#!/bin/sh
2#
3# couchdb Starts CouchDB
4# chkconfig: 2345 84 25
5# description: Apache CouchDB init script
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
17COUCHDB="/usr/bin/couchdb"
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
31 msg_network_down "CouchDB"
32 exit 1
33 fi
34else
35 exit 0
36fi
37
38start() {
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"
53 RETVAL=$?
54 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/couchdb
55}
56
57stop() {
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 --pidfile $COUCHDB_PID couchdb -TERM
66 rm -f /var/lock/subsys/couchdb
67}
68
69reload() {
70 if [ ! -f /var/lock/subsys/couchdb ]; then
71 msg_not_running "CouchDB"
72 RETVAL=7
73 return
74 fi
75
76 msg_reloading "CouchDB"
77 killproc --pidfile $COUCHDB_PID couchdb -HUP
78 RETVAL=$?
79}
80
81condrestart() {
82 if [ ! -f /var/lock/subsys/couchdb ]; then
83 msg_not_running "CouchDB"
84 RETVAL=$1
85 return
86 fi
87
88 stop
89 start
90}
91
92RETVAL=0
93# See how we were called.
94case "$1" in
95 start)
96 start
97 ;;
98 stop)
99 stop
100 ;;
101 restart)
102 stop
103 start
104 ;;
105 try-restart)
106 condrestart 0
107 ;;
108 reload|force-reload)
109 reload
110 ;;
111 status)
112 status couchdb
113 RETVAL=$?
114 ;;
115 *)
116 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
117 exit 3
118esac
119
120exit $RETVAL
This page took 0.075158 seconds and 4 git commands to generate.