forked from dpoulson/ginlong-mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ginlong.init
40 lines (38 loc) · 947 Bytes
/
ginlong.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/sh
### BEGIN INIT INFO
# Provides: ginlong-mqtt
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ginlong MQTT listener
# Description: Listens for connections from a ginlong solar inverter, and pipes the output to MQTT
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/pi/ginlong
NAME=ginlong-listen.py
DAEMON_PATH=/home/pi/ginlong
PIDFILE=/var/run/$NAME.pid
case "$1" in
start)
echo -n "Starting ginlong: "
start-stop-daemon --start --pidfile $PIDFILE --make-pidfile --background --no-close --chdir $DAEMON_PATH --exec $NAME > /dev/null 2>&1
echo "done."
;;
stop)
echo -n "Stopping ginlong: "
start-stop-daemon --stop --quiet --pidfile $PIDFILE
rm $PIDFILE
echo "done."
;;
restart)
echo "Restarting ginlong: "
sh $0 stop
sleep 10
sh $0 start
;;
*)
echo "Usage: /etc/init.d/z-way-server {start|stop|restart|save}"
exit 1
;;
esac
exit 0