-
Notifications
You must be signed in to change notification settings - Fork 0
/
esmart_fsm
executable file
·54 lines (48 loc) · 1.38 KB
/
esmart_fsm
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# -*- coding: utf-8 -*-
#
# eSmart/heattrap controller
#
# Copyright (2020) Jonathan Schultz
#
# /etc/init.d/sample.py
### BEGIN INIT INFO
# Provides: esmart_fsm.py
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=esmart_fsm
#This is the command to be run, give the full pathname
DAEMON="/usr/bin/python3 /home/pi/esmart-tools/esmart_fsm.py"
DAEMON_OPTS=""
DAEMON_LOG="/var/log/esmart_fsm.log"
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
echo -n "Starting daemon: "$NAME
start-stop-daemon --start --background --quiet --no-close --exec $DAEMON -- $DAEMON_OPTS >> $DAEMON_LOG 2>&1
echo "."
;;
stop)
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
echo "."
;;
restart)
echo -n "Restarting daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --retry 30 --exec $DAEMON
start-stop-daemon --start --background --quiet --no-close --exec $DAEMON -- $DAEMON_OPTS >> $DAEMON_LOG 2>&1
echo "."
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0