Use printf instead of echo -n
[yazpp-moved-to-github.git] / src / yaz-proxy.sh
1 #!/bin/sh
2 #
3 # skeleton      example file to build /etc/init.d/ scripts.
4 #               This file should be used to construct scripts for /etc/init.d.
5 #
6 #               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
7 #               Modified for Debian GNU/Linux
8 #               by Ian Murdock <imurdock@gnu.ai.mit.edu>.
9 #
10 # Version:      @(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
11 #
12 PATH=/usr/local/bin:/bin:/usr/bin
13 export PATH
14
15 # Proxy CWD is here. Should be writable by it.
16 DIR=/var/yaz-proxy
17 # Proxy Path
18 DAEMON="/usr/local/bin/yaz-proxy"
19
20 # Proxy PIDFILE. Must be writable by it.
21 PIDFILE="/var/run/yaz-proxy.pid"
22
23 # Log file
24 LOGFILE=/var/log/yaz-proxy.log
25
26 # Port
27 PORT=9000
28
29 # Run as this user. Set to empty to keep uid as is
30 RUNAS=nobody
31
32 # Extra args . Config file _WITH_ option
33 ARGS="-c config.xml"
34
35 if test -n "RUNAS"; then
36         ARGS="-u $RUNAS $ARGS"
37 fi
38
39 # Name, Description (not essential)
40 NAME=yaz-proxy
41 DESC="YAZ proxy"
42
43 test -d $DIR || exit 0
44 test -f $DAEMON || exit 0
45
46 set -e
47
48 case "$1" in
49   start)
50         printf "%s" "Starting $DESC: "
51         cd $DIR
52         $DAEMON -l $LOGFILE -p $PIDFILE $ARGS @:$PORT &
53         echo "$NAME."
54         ;;
55   stop)
56         printf "%s" "Stopping $DESC: "
57
58         if test -f $PIDFILE; then
59                 kill `cat $PIDFILE`
60                 rm -f $PIDFILE
61                 echo "$NAME."
62         else
63                 echo "No PID $PIDFILE"
64         fi
65         ;;
66   reload)
67         if test -f $PIDFILE; then
68                 kill -HUP `cat $PIDFILE`
69         fi
70   ;;
71   restart|force-reload)
72         printf "%s" "Restarting $DESC: "
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