X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=etc%2Finit.d%2Fidzebra-init-script;fp=etc%2Finit.d%2Fidzebra-init-script;h=8d70997a585cff26f787d0d91831cc757fe53d59;hp=0000000000000000000000000000000000000000;hb=3f95bc864e6652d442488242b4d0b14da816e9a6;hpb=871d1504333ccd4dd85c2c80cbc1027ab9364532 diff --git a/etc/init.d/idzebra-init-script b/etc/init.d/idzebra-init-script new file mode 100755 index 0000000..8d70997 --- /dev/null +++ b/etc/init.d/idzebra-init-script @@ -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