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