#!/bin/sh # # couchdb Apache CouchDB init script # chkconfig: 2345 84 25 # description: Apache CouchDB init script for the database server. # pidfile: /var/run/couchdb.pid # # $Id$ # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network # Set defaults COUCHDB="/usr/bin/couchdb" COUCHDB_INI='/etc/apache-couchdb/couch.ini' COUCHDB_PID='/var/run/couchdb.pid' COUCHDB_USER='couchdb' COUCHDB_STDOUT='/dev/null' COUCHDB_STDERR='/dev/null' COUCHDB_RESPAWN_TIMEOUT='0' # Get service config - may override defaults [ -f /etc/sysconfig/couchdb ] && . /etc/sysconfig/couchdb # Check that networking is up. if is_yes "${NETWORKING}"; then if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then msg_network_down "CouchDB" exit 1 fi else exit 0 fi start() { # Check if the service is already running? if [ -f /var/lock/subsys/couchdb ]; then msg_already_running "CouchDB" return fi msg_starting "CouchDB" test -n $COUCHDB_PID \ && touch $COUCHDB_PID \ && chown $COUCHDB_USER $COUCHDB_PID daemon --user $COUCHDB_USER $COUCHDB \ -b -c "$COUCHDB_INI" -p "$COUCHDB_PID" \ -o "$COUCHDB_STDOUT" -e "$COUCHDB_STDERR" \ -r "$COUCHDB_RESPAWN_TIMEOUT" \ $COUCHDB_OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/couchdb } stop() { if [ ! -f /var/lock/subsys/couchdb ]; then msg_not_running "CouchDB" return fi # Stop daemons. msg_stopping "CouchDB" su $COUCHDB_USER -c "$COUCHDB -d $COUCHDB_OPTIONS" RETVAL=$? if [ $RETVAL -eq 0 ]; then ok else fail fi rm -f $COUCHDB_PID rm -f /var/lock/subsys/couchdb } reload() { if [ ! -f /var/lock/subsys/couchdb ]; then msg_not_running "CouchDB" RETVAL=7 return fi msg_reloading "CouchDB" killproc --pidfile $COUCHDB_PID couchdb -HUP RETVAL=$? } condrestart() { if [ ! -f /var/lock/subsys/couchdb ]; then msg_not_running "CouchDB" RETVAL=$1 return fi stop start } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop start ;; try-restart) condrestart 0 ;; reload|force-reload) reload ;; status) # Display the status of the running Apache CouchDB process. $COUCHDB -s status couchdb RETVAL=$? ;; *) msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" exit 3 esac exit $RETVAL