forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goecheck.sh
76 lines (75 loc) · 2.93 KB
/
goecheck.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
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
#!/bin/bash
goecheck(){
#######################################
#goe mobility check
if [[ $evsecon == "goe" ]]; then
output=$(curl --connect-timeout 1 -s http://$goeiplp1/status)
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.alw')
if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatus"; then
lp1enabled=$(</var/www/html/openWB/ramdisk/lp1enabled)
if ((state == "0")) && (( lp1enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=1 > /dev/null
fi
fi
if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatus"; then
if ((state == "1")) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=alw=0 > /dev/null
fi
fi
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsoll)
if (( oldcurrent != $current )) ; then
curl --silent --connect-timeout $goetimeoutlp1 -s http://$goeiplp1/mqtt?payload=amp=$current > /dev/null
fi
fi
fi
if [[ $lastmanagement == "1" ]]; then
if [[ $evsecons1 == "goe" ]]; then
output=$(curl --connect-timeout 1 -s http://$goeiplp2/status)
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.alw')
if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss1"; then
lp2enabled=$(</var/www/html/openWB/ramdisk/lp2enabled)
if ((state == "0")) && (( lp2enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=1 > /dev/null
fi
fi
if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss1"; then
if ((state == "1")) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=alw=0 > /dev/null
fi
fi
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsolls1)
if (( oldcurrent != $current )) ; then
curl --silent --connect-timeout $goetimeoutlp2 -s http://$goeiplp2/mqtt?payload=amp=$current > /dev/null
fi
fi
fi
if [[ $lastmanagements2 == "1" ]]; then
if [[ $evsecons2 == "goe" ]]; then
output=$(curl --connect-timeout 1 -s http://$goeiplp3/status)
if [[ $? == "0" ]] ; then
state=$(echo $output | jq -r '.alw')
if grep -q 1 "/var/www/html/openWB/ramdisk/ladestatuss2"; then
lp3enabled=$(</var/www/html/openWB/ramdisk/lp3enabled)
if ((state == "0")) && (( lp3enabled == "1" )) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=alw=1 > /dev/null
fi
fi
if grep -q 0 "/var/www/html/openWB/ramdisk/ladestatuss2"; then
if ((state == "1")) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=alw=0 > /dev/null
fi
fi
oldcurrent=$(echo $output | jq -r '.amp')
current=$(</var/www/html/openWB/ramdisk/llsolls2)
if (( oldcurrent != $current )) ; then
curl --silent --connect-timeout $goetimeoutlp3 -s http://$goeiplp3/mqtt?payload=amp=$current > /dev/null
fi
fi
fi
fi
fi
}