VendServer - add writing traceback to file on SIGUSR1
[uccvend-vendserver.git] / bin / init.d / vendserver
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          vendserver
4 # Required-Start:    $syslog
5 # Required-Stop:     $syslog
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: VendServer
9 # Description:       Dispense2 Vending Machine / MIFARE Server
10 ### END INIT INFO
11
12 # Author: Bob Adamson
13
14 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games
15 DESC="VendServer"
16 NAME=vendserver
17 DAEMON="/usr/local/uccvend-vendserver/vendserver"
18 PIDFILE=/var/run/$NAME.pid
19 TBFILE=/var/run/vendtraces.log
20 SCRIPTNAME=/etc/init.d/$NAME
21 DAEMON_ARGS=""
22
23 # Say something and gracefully exit if the package has been removed.
24 if ! test -x $DAEMON; then
25         echo "Failed to find the executable $DAEMON"
26         exit 1
27 fi
28
29
30 d_start() {
31         start-stop-daemon --start --pidfile $PIDFILE --nicelevel 5 \
32                 --startas $DAEMON -- -d -sdaemon --pid-file=$PIDFILE \
33                 --traceback-file=$TBFILE $DAEMON_ARGS
34 }
35
36 d_stop() {
37         start-stop-daemon --stop --pidfile $PIDFILE
38 }
39
40 case "$1" in
41         start)
42                 echo -n "Starting $DESC: $NAME\n"
43                 d_start
44                 echo "."
45                 ;;
46         stop)
47                 echo -n "Stopping $DESC: $NAME\n"
48                 d_stop
49                 echo "."
50                 ;;
51         restart|force-reload)
52                 echo -n "Restarting $DESC: $NAME\n"
53                 d_stop
54                 sleep 1
55                 d_start
56                 echo "."
57                 ;;
58         *)
59                 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
60                 exit 1
61                 ;;
62 esac
63
64 exit 0

UCC git Repository :: git.ucc.asn.au