-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensorTool
executable file
·114 lines (109 loc) · 3.19 KB
/
sensorTool
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/sh
### BEGIN INIT INFO
# Provides: sensorTool
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts up the sensorTool scripts.
# Description: This service is used to gather data from different sources and send them to the cloud server/database. Furthermore, it adds an URL link to the local IP.
### END INIT INFO
MYPATH="/home/pi/sensorTool/python"
LOGFILE1="/var/sensorTool/sensorService.log"
LOGFILE2="/var/sensorTool/sensorLogic.log"
SCRIPT1="sensorService.py"
SCRIPT2="sensorLogic.py"
SCRIPT3="/home/pi/sensorTool/sh/checkSensorTool.sh"
case "$1" in
start)
echo "Timeservice force update"
service ntp stop
ntpd -q -g -x -n
service ntp start
sleep 20
echo "preparing www"
mkdir /var/sensorTool/www
cp /home/pi/sensorTool/www/* /var/sensorTool/www/
chown -R pi.pi /var/sensorTool/www
chmod 666 /var/sensorTool/www/dynamic.conf
chmod 666 /var/sensorTool/www/webradio.station
chmod 666 /var/sensorTool/www/switchstate.csv
ln -s /home/pi/pics/ /var/sensorTool/www/pcis
sleep 2
service apache2 restart
echo "Starting sensorTool"
echo '' > $LOGFILE1
echo '' > $LOGFILE2
$MYPATH/$SCRIPT1 start >>$LOGFILE1 2>&1 &
$MYPATH/$SCRIPT2 start >>$LOGFILE2 2>&1 &
echo "Stop pilight service" #only needed for switching, when necessery
sleep 10
service pilight stop
;;
test)
$MYPATH/$SCRIPT1 test >/dev/null 2>&1 &
$MYPATH/$SCRIPT2 test
;;
testService)
echo "(Re)Starting ".$SCRIPT1." in verbose mode"
killall $SCRIPT1 >/dev/null 2>&1
$MYPATH/$SCRIPT1 test
;;
testLogic)
echo "(Re)Starting ".$SCRIPT2." in verbose mode"
killall $SCRIPT2 >/dev/null 2>&1
$MYPATH/$SCRIPT2 test
;;
status)
echo "(Re)Starting ".$SCRIPT3." in verbose mode"
$SCRIPT3
;;
stop)
echo "Stopping sensorTool"
killall $SCRIPT1 >/dev/null 2>&1
sleep 1
killall $SCRIPT2 >/dev/null 2>&1
sleep 1
killall $SCRIPT3 >/dev/null 2>&1
sleep 1
killall mplayer
/home/pi/RelaisSchalten aus
/home/pi/LedSchalten aus
;;
restart)
echo "Restarting sensorTool"
echo "Stopping sensorTool"
killall $SCRIPT1 >/dev/null 2>&1
sleep 1
killall $SCRIPT2 >/dev/null 2>&1
sleep 1
killall $SCRIPT3 >/dev/null 2>&1
sleep 1
killall mplayer
/home/pi/RelaisSchalten aus
/home/pi/LedSchalten aus
echo "preparing..."
mkdir /var/sensorTool/www
rm -f /var/sensorTool/*.*
rm -f /var/sensorTool/www/*
cp /home/pi/sensorTool/www/* /var/sensorTool/www/
chown -R pi.pi /var/sensorTool/www
chmod 666 /var/sensorTool/www/dynamic.conf
chmod 666 /var/sensorTool/www/webradio.station
sleep 2
service apache2 restart
echo "Starting sensorTool"
echo '' > $LOGFILE1
echo '' > $LOGFILE2
$MYPATH/$SCRIPT1 start >>$LOGFILE1 &
$MYPATH/$SCRIPT2 start >>$LOGFILE2 2>&1 &
echo "Stop pilight service" #only needed for switching, when necessery
sleep 2
service pilight stop
;;
*)
echo "Usage: service sensorTool start|stop|testService|testLogic|status"
exit 1
;;
esac
exit 0