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