forked from RobertJansen1/stairlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.sh
executable file
·40 lines (40 loc) · 1.13 KB
/
check.sh
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/bash
DIFF=$(diff /run/shm/trap.log /run/shm/trapdiff.log)
if [ "$DIFF" != "" ]
then
#echo "The file was modified"
mv /run/shm/new.log /run/shm/old.log
grep triggered /run/shm/trap.log > /run/shm/new.log
diff /run/shm/old.log /run/shm/new.log
rm -f /run/shm/trapdiff.log
touch /run/shm/trap.log
cp /run/shm/trap.log /run/shm/trapdiff.log
else
echo "Het trap-script is opnieuw afgetrapt."
rm -f /run/shm/trap.log
rm -f /run/shm/trapdiff.log
pkill -f pigpiod
pkill -f trap.py
touch /run/shm/trap.log
touch /run/shm/trapdiff.log
sleep 2
pigpiod -a1
sleep 2
nohup python /opt/trap/trap.py > /dev/null &
fi
DIFF2=$(diff /opt/trap/variables.py /opt/trap/diffvariables.py)
if [ "$DIFF2" != "" ]
then
echo "Het trap-script is opnieuw afgetrapt.(variables)"
cp /opt/trap/variables.py /opt/trap/diffvariables.py
rm -f /run/shm/trap.log
rm -f /run/shm/trapdiff.log
pkill -f pigpiod
pkill -f trap.py
touch /run/shm/trap.log
touch /run/shm/trapdiff.log
sleep 2
pigpiod -a1
sleep 2
nohup python /opt/trap/trap.py > /dev/null &
fi