Author: japhy                        Date: Sun Jun  8 13:19:25 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new file: init script for couchdb

---- Files affected:
SOURCES:
   couchdb.init (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/couchdb.init
diff -u /dev/null SOURCES/couchdb.init:1.1
--- /dev/null   Sun Jun  8 15:19:25 2008
+++ SOURCES/couchdb.init        Sun Jun  8 15:19:20 2008
@@ -0,0 +1,124 @@
+#!/bin/sh
+#
+# couchdb      apache couchdb init script
+#
+# chkconfig:   345 85 25
+#
+# description: apache couchdb init script
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Set defaults
+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='5'
+
+# 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_starting couchdb
+                test -n $COUCHDB_PID \
+                    && touch $COUCHDB_PID \
+                    && chown $COUCHDB_USER $COUCHDB_PID
+               daemon --user $COUCHDB_USER /usr/bin/couchdb \
+                    -b -c "$COUCHDB_INI" -p "$COUCHDB_PID" \
+                    -o "$COUCHDB_STDOUT" -e "$COUCHDB_STDERR" \
+                    -r "$COUCHDB_RESPAWN"
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/couchdb
+       else
+               msg_already_running couchdb
+       fi
+}
+
+stop() {
+       if [ -f /var/lock/subsys/couchdb ]; then
+               # Stop daemons.
+               msg_stopping couchdb
+               killproc couchdb
+               killproc --pidfile $COUCHDB_PID couchdb -TERM
+               rm -f /var/lock/subsys/couchdb
+       else
+               msg_not_running couchdb
+       fi
+}
+
+reload() {
+       if [ -f /var/lock/subsys/couchdb ]; then
+               msg_reloading couchdb
+               killproc couchdb -HUP
+               killproc --pidfile $COUCHDB_PID couchdb -HUP
+               RETVAL=$?
+       else
+               msg_not_running couchdb
+               RETVAL=7
+       fi
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/couchdb ]; then
+               stop
+               start
+       else
+               msg_not_running couchdb
+               RETVAL=$1
+       fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+# include force-reload here if program allows reloading without restart
+# otherwise remove reload action and support force-reload as restart if running
+  reload|force-reload)
+       reload
+       ;;
+# use this one if program doesn't support reloading without restart
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       status couchdb
+       RETVAL=$?
+       ;;
+  *)
+       msg_usage "$0 
{start|stop|restart|try-restart|reload|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to