Test for preferred target and block=preferred
[pazpar2-moved-to-github.git] / src / pazpar2.sh
1 #!/bin/sh
2 #
3 # pazpar2.sh - pazpar2 start/stop script
4
5 : ${PAZPAR2_HOME=$HOME/pazpar2}
6 : ${pazpar2_program=$PAZPAR2_HOME/src/pazpar2}
7 : ${pazpar2_config=$PAZPAR2_HOME/etc/pazpar2.cfg}
8 : ${pazpar2_pid=$PAZPAR2_HOME/pazpar2.pid}
9 : ${pazpar2_log=$PAZPAR2_HOME/pazpar2.log}
10
11 command=$1; shift
12
13 case "$command" in
14         start)
15                 $pazpar2_program -D -l $pazpar2_log -p $pazpar2_pid -f $pazpar2_config "$@"
16                 ;;
17
18         stop) 
19                 test -f $pazpar2_pid && \
20                         kill -0 `cat $pazpar2_pid` 2>/dev/null && \
21                         kill -TERM `cat $pazpar2_pid`
22                 ;;
23
24         # graceful restart - not yet implemented by pazpar2
25         graceful)
26                 test -f $pazpar2_pid && kill -HUP `cat $pazpar2_pid`
27                 ;;
28
29         restart)
30                 $0 stop
31                 sleep 1         # let the OS give the port address free
32                 $0 start "$@"
33                 ;;
34
35         *)
36         echo "Usage: `basename $0` [ start [pazpar2 options]] [ stop | restart ]" >&2
37         ;;
38 esac
39
40 exit 0
41