Permalink
Browse files

Added init script

  • Loading branch information...
dpoulson committed Oct 27, 2017
1 parent dc90b45 commit 8a0e299e693b29255fdf4951b27b78269cee88ee
Showing with 40 additions and 0 deletions.
  1. +40 −0 ginlong-mqtt.init
View
@@ -0,0 +1,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-mqtt
NAME=ginlong-listen.py
DAEMON_PATH=/home/pi/ginlong-mqtt
PIDFILE=/var/run/$NAME.pid
case "$1" in
start)
echo -n "Starting ginlong-mqtt: "
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-mqtt: "
start-stop-daemon --stop --quiet --pidfile $PIDFILE
rm $PIDFILE
echo "done."
;;
restart)
echo "Restarting ginlong-mqtt: "
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

0 comments on commit 8a0e299

Please sign in to comment.