Fix documentation of of chr's equivalent directive ZEB-672
[idzebra-moved-to-github.git] / etc / init.d / idzebra-init-script
1 #! /bin/sh
2
3 # This is a startup/shutdown script for Index Data's Zebra server,
4 # suitable for use in a SysV-style init directory such as /etc/init.d
5 # (on Debian systems) and /etc/rc.d/init.d (on Red Hat systems), like
6 # this:
7 #
8 #       sudo cp idzebra-init-script /etc/init.d/idzebra
9 #       sudo /etc/init.d/idzebra start
10 #
11 # You may need to tweak it to suit your system's paths.
12
13 # zebrasrv-2.0 may be in /usr/local/bin, hence this slight security hole
14 PATH=/bin:/usr/bin:/usr/local/bin/
15 catfile=/usr/local/src/cvs/zebra/etc/init.d/catalogue
16
17 case "$1" in
18     start)
19         while read line; do
20             line=`echo "$line" | sed 's/#.*//'`
21             line=`echo "$line" | sed 's/[ \t]*$//'`
22             if [ "x$line" != x ]; then
23                 set $line; tag=$1; dir=$2; file=$3
24                 #echo "tag='$tag', dir='$dir', file='$file'"
25
26                 logfile=/var/log/zebra-$tag
27                 pidfile=/var/run/zebra-$tag.pid
28                 if [ -f $pidfile ]; then
29                         echo "Zebra service '$tag' seems to be already running"
30                         continue
31                 fi
32                 echo "Starting Zebra service '$tag'"
33                 test -f $logfile && mv $logfile $logfile.old
34                 case "$file" in
35                   *.xml) opt=-f;;
36                   *.cfg) opt=-c;;
37                   *) echo "Unrecognised Zebra config-file type: '$file'";;
38                 esac
39
40                 (
41                     cd $dir
42                     echo === $dir zebrasrv-2.0 $opt $file === < /dev/null > $logfile 2>&1
43                     ( zebrasrv-2.0 $opt $file < /dev/null >> $logfile 2>&1 & )
44                     echo $! > $pidfile
45                 )
46             fi
47         done < $catfile
48         ;;
49
50     stop)
51         # Unfortunate partial duplication of parsing code here
52         while read line; do
53             line=`echo "$line" | sed 's/#.*//'`
54             line=`echo "$line" | sed 's/[ \t]*$//'`
55             if [ "x$line" != x ]; then
56                 set $line; tag=$1
57
58                 pidfile=/var/run/zebra-$tag.pid
59                 if [ ! -f $pidfile ]; then
60                         echo "Zebra service '$tag' does not seem to be running"
61                         continue
62                 fi
63
64                 echo "Stopping Zebra service '$tag'"
65                 kill `cat $pidfile`
66                 rm $pidfile
67             fi
68         done < $catfile
69         ;;
70
71     restart)
72         $0 stop && $0 start
73         ;;
74     *)
75         echo "Usage: $0 start|stop|restart" >&2
76         ;;
77 esac