New
authorMike Taylor <mike@indexdata.com>
Wed, 31 Jan 2007 12:26:50 +0000 (12:26 +0000)
committerMike Taylor <mike@indexdata.com>
Wed, 31 Jan 2007 12:26:50 +0000 (12:26 +0000)
etc/init.d/catalogue [new file with mode: 0644]
etc/init.d/idzebra-init-script [new file with mode: 0755]

diff --git a/etc/init.d/catalogue b/etc/init.d/catalogue
new file mode 100644 (file)
index 0000000..8ba5f60
--- /dev/null
@@ -0,0 +1,16 @@
+# $Id: catalogue,v 1.1 2007-01-31 12:26:50 mike Exp $
+#
+# Zebra catalogue -- specifies which Zebra services the
+# /etc/init.d/idzebra script should start up and and shut down.
+#
+# Comments, introduced by the hash character (#) are ignored, and
+# blank linkes are ignored.  Every other line describes a single Zebra
+# service.  Each such line consist of three whitespace-separated
+# fields: a short tag used to make service-specific filenames, the
+# path to the directory that Zebra should run in, and the name of the
+# master configuration file of the service's configuration (relative
+# to the directory)
+
+gils   /usr/local/src/cvs/zebra/examples/gils zebra.cfg
+irspy  /usr/local/src/cvs/irspy/zebra yazserver.xml
+alvis  /usr/local/src/cvs/alvis/zebra/alvisxsltconfig db2/yazserver.xml
diff --git a/etc/init.d/idzebra-init-script b/etc/init.d/idzebra-init-script
new file mode 100755 (executable)
index 0000000..8d70997
--- /dev/null
@@ -0,0 +1,79 @@
+#! /bin/sh
+
+# $Id: idzebra-init-script,v 1.1 2007-01-31 12:26:50 mike Exp $
+#
+# This is a startup/shutdown script for Index Data's Zebra server,
+# suitable for use in a SysV-style init directory such as /etc/init.d
+# (on Debian systems) and /etc/rc.d/init.d (on Red Hat systems), like
+# this:
+#
+#      sudo cp idzebra-init-script /etc/init.d/idzebra
+#      sudo /etc/init.d/idzebra start
+#
+# You may need to tweak it to suit your system's paths.
+
+# zebrasrv-2.0 may be in /usr/local/bin, hence this slight security hole
+PATH=/bin:/usr/bin:/usr/local/bin/
+catfile=/usr/local/src/cvs/zebra/etc/init.d/catalogue
+
+case "$1" in
+    start)
+       while read line; do
+           line=`echo "$line" | sed 's/#.*//'`
+           line=`echo "$line" | sed 's/[ \t]*$//'`
+           if [ "x$line" != x ]; then
+               set $line; tag=$1; dir=$2; file=$3
+               #echo "tag='$tag', dir='$dir', file='$file'"
+
+               logfile=/var/log/zebra-$tag
+               pidfile=/var/run/zebra-$tag.pid
+               if [ -f $pidfile ]; then
+                       echo "Zebra service '$tag' seems to be already running"
+                       continue
+               fi
+               echo "Starting Zebra service '$tag'"
+               test -f $logfile && mv $logfile $logfile.old
+               case "$file" in
+                 *.xml) opt=-f;;
+                 *.cfg) opt=-c;;
+                 *) echo "Unrecognised Zebra config-file type: '$file'";;
+               esac
+
+               (
+                   cd $dir
+                   echo === $dir zebrasrv-2.0 $opt $file === < /dev/null > $logfile 2>&1
+                   ( zebrasrv-2.0 $opt $file < /dev/null >> $logfile 2>&1 & )
+                   echo $! > $pidfile
+               )
+           fi
+       done < $catfile
+       ;;
+
+    stop)
+       # Unfortunate partial duplication of parsing code here
+       while read line; do
+           line=`echo "$line" | sed 's/#.*//'`
+           line=`echo "$line" | sed 's/[ \t]*$//'`
+           if [ "x$line" != x ]; then
+               set $line; tag=$1
+
+               pidfile=/var/run/zebra-$tag.pid
+               if [ ! -f $pidfile ]; then
+                       echo "Zebra service '$tag' does not seem to be running"
+                       continue
+               fi
+
+               echo "Stopping Zebra service '$tag'"
+               kill `cat $pidfile`
+               rm $pidfile
+           fi
+       done < $catfile
+       ;;
+
+    restart)
+       $0 stop && $0 start
+       ;;
+    *)
+       echo "Usage: $0 start|stop|restart" >&2
+        ;;
+esac