Note unpacking
[irspy-moved-to-github.git] / zebra / init-script
1 #! /bin/sh
2
3 # $Id: init-script,v 1.7 2007-03-23 09:30:31 mike 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     *) echo "$0: unsupported host `hostname`" >&2
25         exit 1;;
26 esac
27
28 case "$1" in
29   start)
30         if [ -f $pidfile ]; then
31                 echo "IRSpy's Zebra seems to be already running"
32                 exit 1
33         fi
34         echo "Starting IRSpy's Zebra"
35         # Let log rotation take care of backups
36         #test -f $logfile && mv -f $logfile $logfile.old
37         ( cd $IRSPYDIR/zebra
38           zebrasrv-2.0 -f yazserver.xml < /dev/null >> $logfile 2>&1 &
39           echo $! > $pidfile
40         )
41         ;;
42   stop)
43         if [ ! -f $pidfile ]; then
44                 echo "IRSpy's Zebra does not seem to be running"
45                 exit 1
46         fi
47         echo "Stopping IRSpy's Zebra"
48         kill `cat $pidfile`
49         rm $pidfile
50         ;;
51   restart)
52         $0 stop && $0 start
53         ;;
54   *)
55         echo "Usage: $0 start|stop|restart" >&2
56         ;;
57 esac