Add support for apache2
[irspy-moved-to-github.git] / zebra / init-script
1 #! /bin/sh
2
3 # $Id: init-script,v 1.8 2009-04-15 18:16:46 wosch Exp $
4 #
5 # This is a startup/shutdown script for IRSpy's Zebra server, suitable
6 # for use in a SysV-style init directory such as /etc/init.d (on
7 # Debian systems) and /etc/rc.d/init.d (on Red Hat systems), like this:
8 #
9 #       cd /etc/init.d
10 #       sudo ln -s .../irspy/zebra/init-script irspy-zebra
11 #       sudo /etc/init.d/irspy-zebra start
12 #
13 # You may need to tweak it to suit your system's paths.
14
15
16 # zebrasrv-2.0 may be in /usr/local/bin, hence this slight security hole
17 PATH=/bin:/usr/bin:/usr/local/bin/
18 logfile=/var/log/irspy-zebra
19 pidfile=/var/run/irspy-zebra.pid
20
21 case "`hostname`" in
22     xeno|rafa|test) IRSPYDIR=/usr/local/src/cvs/irspy/;;
23     shawarma|kafta) IRSPYDIR=/home/mike/cvs/irspy/;;
24     us2| us2.*) 
25         IRSPYDIR=/home/wosch/indexdata/irspy/
26         logfile=$IRSPYDIR/irspy-zebra
27         pidfile=$IRSPYDIR/irspy-zebra.pid
28         ;;
29     *) echo "$0: unsupported host `hostname`" >&2
30         exit 1;;
31 esac
32
33 case "$1" in
34   start)
35         if [ -f $pidfile ]; then
36                 echo "IRSpy's Zebra seems to be already running"
37                 exit 1
38         fi
39         echo "Starting IRSpy's Zebra"
40         # Let log rotation take care of backups
41         #test -f $logfile && mv -f $logfile $logfile.old
42         ( cd $IRSPYDIR/zebra
43           zebrasrv-2.0 -f yazserver.xml < /dev/null >> $logfile 2>&1 &
44           echo $! > $pidfile
45         )
46         ;;
47   stop)
48         if [ ! -f $pidfile ]; then
49                 echo "IRSpy's Zebra does not seem to be running"
50                 exit 1
51         fi
52         echo "Stopping IRSpy's Zebra"
53         kill `cat $pidfile`
54         rm $pidfile
55         ;;
56   restart)
57         $0 stop && $0 start
58         ;;
59   *)
60         echo "Usage: $0 start|stop|restart" >&2
61         ;;
62 esac