]> git.pld-linux.org Git - packages/apache-couchdb.git/blame - apache-couchdb.init
- 1.0.2
[packages/apache-couchdb.git] / apache-couchdb.init
CommitLineData
8ed0acf8 1#!/bin/sh
2#
3# couchdb Starts CouchDB
4#
5# chkconfig: 2345 84 25
6# description: Apache CouchDB init script
7# pidfile: /var/run/couchdb.pid
8
9# Source function library
10. /etc/rc.d/init.d/functions
11
12# defaults
13COUCHDB=/usr/bin/couchdb
14RUN_DIR=/var/run/couchdb
15COUCHDB_USER=root
16
17# Get service config
18if [ -f /etc/sysconfig/couchdb ]; then
19 . /etc/sysconfig/couchdb
20fi
21
22
23start() {
24 # Check if the service is already running?
25 if [ ! -f /var/lock/subsys/couchdb ]; then
26 msg_starting "CouchDB"
27
28 command="$COUCHDB -b -p /var/run/couchdb.pid"
29 #command="$COUCHDB"
30 if test -n "$COUCHDB_STDOUT_FILE"; then
31 command="$command -o $COUCHDB_STDOUT_FILE"
32 fi
33
34 if test -n "$COUCHDB_STDERR_FILE"; then
35 command="$command -e $COUCHDB_STDERR_FILE"
36 fi
37
38 if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then
39 command="$command -r $COUCHDB_RESPAWN_TIMEOUT"
40 fi
41
42 if test -n "$COUCHDB_OPTIONS"; then
43 command="$command $COUCHDB_OPTIONS"
44 fi
45
46 # have pidfile
47 touch /var/run/couchdb.pid && chown $COUCHDB_USER /var/run/couchdb.pid && chmod 660 /var/run/couchdb.pid
48
49 su - $COUCHDB_USER -c "$command > /dev/null"
50
51 RETVAL=$?
52 if [ $RETVAL -eq 0 ]; then
53 touch /var/lock/subsys/couchdb
54 ok
55 else
56 fail
57 fi
58 else
59 msg_already_running "CouchDB"
60 fi
61}
62
63stop() {
64 if [ -f /var/lock/subsys/couchdb ]; then
65 msg_stopping "CouchDB"
66
67 command="$COUCHDB -d -p /var/run/couchdb.pid"
68
69 su - $COUCHDB_USER -c "$command > /dev/null";
70
71 RETVAL=$?
72 if [ $RETVAL -eq 0 ]; then
73 rm -f /var/lock/subsys/couchdb >/dev/null 2>&1
74 ok
75 else
76 fail
77 fi
78
79 else
80 msg_not_running couchdb
81 fi
82}
83
84
85RETVAL=0
86# See how we were called.
87case "$1" in
88 start)
89 start
90 ;;
91 stop)
92 stop
93 ;;
94 restart)
95 stop
96 start
97 ;;
98 status)
99 status couchdb
100 ;;
101 *)
102 msg_usage "$0 {start|stop|restart|status}"
103 exit 3
104esac
105
106exit $RETVAL
This page took 0.067547 seconds and 4 git commands to generate.