annotate eprodbus.sh @ 13:4450cf739263

Add link to protocol document.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 06 Dec 2021 11:25:51 +1030
parents 446cfe74827b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 #! /bin/sh
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 ### BEGIN INIT INFO
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 # Provides: eprodbus
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 # Required-Start: $remote_fs $syslog
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 # Required-Stop: $remote_fs $syslog
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 # Default-Start: 2 3 4 5
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 # Default-Stop: 0 1 6
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 # Short-Description: eprodbus
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 # Description:
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 # Log van stats
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 ### END INIT INFO
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 set -e
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 PIDFILE=/var/run/eprodbus.pid
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 PYTHON=/usr/bin/python
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 DAEMON=/home/root/vanlogger/epro/eprodbus.py
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 test -x ${DAEMON} || exit 0
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 umask 022
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 . /etc/init.d/functions
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 case "$1" in
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 start)
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 echo "Starting eprodbus"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 if start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile ${PIDFILE} --exec ${PYTHON} -- ${DAEMON} ; then
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 exit 0
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 else
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 exit 1
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 fi
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 ;;
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 stop)
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 echo "Stopping eprodbus"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 if start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE}; then
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 rm -f ${PIDFILE}
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 exit 0
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 else
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43 exit 1
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 fi
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 ;;
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47 restart)
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 echo "Restarting eprodbus"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 if start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${PIDFILE}; then
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50 rm -f ${PIDFILE}
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 fi
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 if start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile ${PIDFILE} --exec ${PYTHON} -- ${DAEMON} ; then
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 exit 0
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 else
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 exit 1
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56 fi
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57 ;;
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59 status)
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
60 if [ ! -e ${PIDFILE} ]; then
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
61 running=0
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 else
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63 pid=$(cat ${PIDFILE})
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
64 ps -w | grep -v grep | grep -q "$pid"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
65 running=$((!$?))
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
66 fi
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
67 if [ $running -ne 0 ]; then
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
68 echo "eprodbus (pid $pid) is running..."
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
69 exit 0
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
70 else
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
71 echo "eprodbus is stopped"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
72 exit 1
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
73 fi
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
74 ;;
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
75
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
76 *)
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
77 echo "Usage: $0 {start|stop|restart|status}"
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
78 exit 1
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
79 esac
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
80
446cfe74827b Add program to report epro status to DBus for Venus tools.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
81 exit 0