import current xml dump
[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
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     your-development-machine ) 
24         IRSPYDIR=/home/foobar/indexdata/irspy/
25         logfile=$IRSPYDIR/irspy-zebra
26         pidfile=$IRSPYDIR/irspy-zebra.pid
27         ;;
28     *) echo "$0: unsupported host `hostname`" >&2
29         exit 1;;
30 esac
31
32 case "$1" in
33   start)
34         if [ -f $pidfile ]; then
35                 echo "IRSpy's Zebra seems to be already running"
36                 exit 1
37         fi
38         echo "Starting IRSpy's Zebra"
39         # Let log rotation take care of backups
40         #test -f $logfile && mv -f $logfile $logfile.old
41         ( cd $IRSPYDIR/zebra
42           zebrasrv-2.0 -f yazserver.xml < /dev/null >> $logfile 2>&1 &
43           echo $! > $pidfile
44         )
45         ;;
46   stop)
47         if [ ! -f $pidfile ]; then
48                 echo "IRSpy's Zebra does not seem to be running"
49                 exit 1
50         fi
51         echo "Stopping IRSpy's Zebra"
52         kill `cat $pidfile`
53         rm $pidfile
54         ;;
55   restart)
56         $0 stop && $0 start
57         ;;
58   *)
59         echo "Usage: $0 start|stop|restart" >&2
60         ;;
61 esac
62