Fixed bug #212: make distcheck uses global yaz, not a local one
[yazproxy-moved-to-github.git] / etc / yazproxyctl.sh
1 #!/bin/sh
2 # $Id: yazproxyctl.sh,v 1.2 2004-09-15 20:31:25 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/yazproxy
10 # Proxy Path 
11 DAEMON=/usr/local/bin/yazproxy
12
13 # Proxy PIDFILE. Must be writable by it.
14 PIDFILE="/var/run/yazproxy.pid"
15
16 # Log file
17 LOGFILE=/var/log/yazproxy.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 # Increase number of sockets, if needed
33 #ulimit -n 1050
34
35 # Name, Description (not essential)
36 NAME=yazproxy
37 DESC="YAZ proxy"
38
39 test -d $DIR || exit 0
40 test -f $DAEMON || exit 0
41
42 set -e
43
44 case "$1" in
45   start)
46         printf "%s" "Starting $DESC: "
47         cd $DIR
48         $DAEMON -l $LOGFILE -p $PIDFILE $ARGS @:$PORT &
49         echo "$NAME."
50         ;;
51   stop)
52         printf "%s" "Stopping $DESC: "
53         cd $DIR
54         if test -f $PIDFILE; then
55                 kill `cat $PIDFILE`
56                 rm -f $PIDFILE
57                 echo "$NAME."
58         else
59                 echo "No PID $PIDFILE"
60         fi
61         ;;
62   reload)
63         printf "%s" "Reloading $DESC: "
64         cd $DIR
65         if test -f $PIDFILE; then
66                 kill -HUP `cat $PIDFILE`
67                 echo "$NAME."
68         else
69                 echo "No PID $PIDFILE"
70         fi
71         ;;
72   restart|force-reload)
73         printf "%s" "Restarting $DESC: "
74         cd $DIR
75         if test -f $PIDFILE; then
76                 kill `cat $PIDFILE`
77                 rm -f $PIDFILE
78         fi
79         sleep 1
80         $DAEMON -l $LOGFILE -p $PIDFILE $ARGS @:$PORT &
81         echo "$NAME."
82         ;;
83   *)
84         N=/etc/init.d/$NAME
85         # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
86         echo "Usage: $N {start|stop|restart|force-reload}" >&2
87         exit 1
88         ;;
89 esac
90
91 exit 0