Beginning work on keepalive script
[yazpp-moved-to-github.git] / etc / yaz-proxy.sh
1 #!/bin/sh
2 # $Id: yaz-proxy.sh,v 1.2 2003-10-24 10:33:01 adam Exp $
3 # YAZ proxy start/stop init.d script.
4 #
5 PATH=/usr/local/bin:/bin:/usr/bin
6 export PATH
7
8 # Proxy CWD is here. Should be writable by it.
9 DIR=/var/yaz-proxy
10 # Proxy Path
11 DAEMON="/usr/local/bin/yaz-proxy"
12
13 # Proxy PIDFILE. Must be writable by it.
14 PIDFILE="/var/run/yaz-proxy.pid"
15
16 # Log file
17 LOGFILE=/var/log/yaz-proxy.log
18
19 # Port
20 PORT=9000
21
22 # Run as this user. Set to empty to keep uid as is
23 RUNAS=nobody
24
25 # Extra args . Config file _WITH_ option
26 ARGS="-c config.xml"
27
28 if test -n "RUNAS"; then
29         ARGS="-u $RUNAS $ARGS"
30 fi
31
32 # Name, Description (not essential)
33 NAME=yaz-proxy
34 DESC="YAZ proxy"
35
36 test -d $DIR || exit 0
37 test -f $DAEMON || exit 0
38
39 set -e
40
41 case "$1" in
42   start)
43         printf "%s" "Starting $DESC: "
44         cd $DIR
45         $DAEMON -l $LOGFILE -p $PIDFILE $ARGS @:$PORT &
46         echo "$NAME."
47         ;;
48   stop)
49         printf "%s" "Stopping $DESC: "
50
51         if test -f $PIDFILE; then
52                 kill `cat $PIDFILE`
53                 rm -f $PIDFILE
54                 echo "$NAME."
55         else
56                 echo "No PID $PIDFILE"
57         fi
58         ;;
59   reload)
60         if test -f $PIDFILE; then
61                 kill -HUP `cat $PIDFILE`
62         fi
63   ;;
64   restart|force-reload)
65         printf "%s" "Restarting $DESC: "
66         if test -f $PIDFILE; then
67                 kill `cat $PIDFILE`
68                 rm -f $PIDFILE
69         fi
70         sleep 1
71         cd $DIR
72         $DAEMON -l $LOGFILE -p $PIDFILE $ARGS @:$PORT &
73         echo "$NAME."
74         ;;
75   *)
76         N=/etc/init.d/$NAME
77         # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
78         echo "Usage: $N {start|stop|restart|force-reload}" >&2
79         exit 1
80         ;;
81 esac
82
83 exit 0