#!/bin/sh # # couchdb Starts CouchDB # # chkconfig: 2345 84 25 # description: Apache CouchDB init script # pidfile: /var/run/couchdb.pid # Source function library . /etc/rc.d/init.d/functions # defaults COUCHDB=/usr/bin/couchdb RUN_DIR=/var/run/couchdb COUCHDB_USER=root # Get service config if [ -f /etc/sysconfig/couchdb ]; then . /etc/sysconfig/couchdb fi start() { # Check if the service is already running? if [ ! -f /var/lock/subsys/couchdb ]; then msg_starting "CouchDB" command="$COUCHDB -b -p /var/run/couchdb.pid" #command="$COUCHDB" if test -n "$COUCHDB_STDOUT_FILE"; then command="$command -o $COUCHDB_STDOUT_FILE" fi if test -n "$COUCHDB_STDERR_FILE"; then command="$command -e $COUCHDB_STDERR_FILE" fi if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then command="$command -r $COUCHDB_RESPAWN_TIMEOUT" fi if test -n "$COUCHDB_OPTIONS"; then command="$command $COUCHDB_OPTIONS" fi # have pidfile touch /var/run/couchdb.pid && chown $COUCHDB_USER /var/run/couchdb.pid && chmod 660 /var/run/couchdb.pid su - $COUCHDB_USER -c "$command > /dev/null" RETVAL=$? if [ $RETVAL -eq 0 ]; then touch /var/lock/subsys/couchdb ok else fail fi else msg_already_running "CouchDB" fi } stop() { if [ -f /var/lock/subsys/couchdb ]; then msg_stopping "CouchDB" command="$COUCHDB -d -p /var/run/couchdb.pid" su - $COUCHDB_USER -c "$command > /dev/null"; RETVAL=$? if [ $RETVAL -eq 0 ]; then rm -f /var/lock/subsys/couchdb >/dev/null 2>&1 ok else fail fi else msg_not_running couchdb fi } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) status couchdb ;; *) msg_usage "$0 {start|stop|restart|status}" exit 3 esac exit $RETVAL