LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File couchdb.init of Package couchdb (Project server:database)

#!/bin/sh
#
# couchdb This is the init script for starting up the CouchDB server
#
# chkconfig: - 20 80
# description: Starts and stops the CouchDB daemon that handles \
#	       all database requests.

### BEGIN INIT INFO
# Provides: couchdb
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start: $remote_fs
# Should-Stop: $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: start and stop CouchDB database server
# Description: Apache CouchDB is a distributed, fault-tolerant and 
#              schema-free document-oriented database accessible 
#              via a RESTful HTTP/JSON API
### END INIT INFO

# Source function library.
. /etc/rc.status

rc_reset

COUCHDB_BIN="/usr/bin/couchdb"
COUCHDB_USER="couchdb"
COUCHDB_INIT_FILE="/var/log/couchdb/couchdb.init"
COUCHDB_STDOUT_FILE="/dev/null"
COUCHDB_STDERR_FILE="/var/log/couchdb/couchdb.stderr"
COUCHDB_RESPAWN_TIMEOUT=5
export HOME=/var/lib/couchdb

config="/etc/sysconfig/couchdb"
[ -e $config ] && . $config

lockfile=/var/lock/subsys/couchdb

mkdir -m 755 -p /var/run/couchdb
chown couchdb /var/run/couchdb

case "$1" in
    start)
	echo -n "Starting CouchDB"
	[ -n "$COUCHDB_RESPAWN_TIMEOUT" ] && respawn="-r $COUCHDB_RESPAWN_TIMEOUT"
	startproc -s -u $COUCHDB_USER $COUCHDB_BIN -b \
		-o $COUCHDB_STDOUT_FILE \
		-e $COUCHDB_STDERR_FILE \
		$respawn \
		$COUCHDB_OPTIONS >> $COUCHDB_INIT_FILE 2>&1
        rc_status -v
        ;;
    stop)
	echo -n "Stopping CouchDB"
	sudo -u $COUCHDB_USER $COUCHDB_BIN -d >> $COUCHDB_INIT_FILE 2>&1
        rc_status -v
        ;;
    restart|force-reload)
	$0 stop
	$0 start
	rc_status
        ;;
    status)
	echo -n "Checking for CouchDB"
	su $COUCHDB_USER -c "$COUCHDB_BIN -s" >> $COUCHDB_INIT_FILE 2>&1 || rc_failed 3
	rc_status -v
        ;;
    condrestart|try-restart)
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac
rc_exit