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