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