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