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