-
Notifications
You must be signed in to change notification settings - Fork 204
/
leds.sh
executable file
·126 lines (121 loc) · 3.49 KB
/
leds.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
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
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
ledsteuerung() {
ledstatus=$(<ramdisk/ledstatus)
lademodus=$(<ramdisk/lademodus)
ladestatus=$(<ramdisk/ladestatus)
#0 sofort
#1 min pv
#2 nur pv
#3 stop
#4 standby
ledrunning=$(ps aux |grep '[l]eds.py' | awk '{print $2}')
if (( slavemode == 1 ));then
if (( lp1enabled == 1 )) && (( lp2enabled == 1 )) && (( lastmanagement == 1 )); then
slaveLedStatus="an12"
elif (( lp1enabled == 0 )) && (( lp2enabled == 1 )) && (( lastmanagement == 1 )); then
slaveLedStatus="an2"
elif (( lp1enabled == 1 )) && (( lp2enabled == 0 )); then
slaveLedStatus="an1"
else
slaveLedStatus="aus"
fi
if [[ $ledstatus != $slaveLedStatus ]]; then
sudo python runs/leds.py $slaveLedStatus &
echo $slaveLedStatus > ramdisk/ledstatus
fi
elif (( ladestatus == 1 ));then
if (( lademodus == 0 )); then
if [[ $ledstatus != $ledsofort ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $ledsofort &
echo $ledsofort > ramdisk/ledstatus
fi
fi
if (( lademodus == 1 )); then
if [[ $ledstatus != $ledminpv ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $ledminpv &
echo $ledminpv > ramdisk/ledstatus
fi
fi
if (( lademodus == 2 )); then
if [[ $ledstatus != $lednurpv ]]; then
if [ ! -z "$ledrunning" ]; then
echo "kill"
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $lednurpv &
echo $lednurpv > ramdisk/ledstatus
fi
fi
if (( lademodus == 3 )); then
if [[ $ledstatus != $ledstop ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $ledstop &
echo $ledstop > ramdisk/ledstatus
fi
fi
if (( lademodus == 4 )); then
if [[ $ledstatus != $ledstandby ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $ledstandby &
echo $ledstandby > ramdisk/ledstatus
fi
fi
else
if (( lademodus == 0 )); then
if [[ $ledstatus != $led0sofort ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $led0sofort &
echo $led0sofort > ramdisk/ledstatus
fi
fi
if (( lademodus == 1 )); then
if [[ $ledstatus != $led0minpv ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $led0minpv &
echo $led0minpv > ramdisk/ledstatus
fi
fi
if (( lademodus == 2 )); then
if [[ $ledstatus != $led0nurpv ]]; then
if [ ! -z "$ledrunning" ]; then
echo "kill"
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $led0nurpv &
echo $led0nurpv > ramdisk/ledstatus
fi
fi
if (( lademodus == 3 )); then
if [[ $ledstatus != $led0stop ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $led0stop &
echo $led0stop > ramdisk/ledstatus
fi
fi
if (( lademodus == 4 )); then
if [[ $ledstatus != $led0standby ]]; then
if [ ! -z "$ledrunning" ]; then
sudo kill $(ps aux |grep '[l]eds.py' | awk '{print $2}')
fi
sudo python runs/leds.py $led0standby &
echo $led0standby > ramdisk/ledstatus
fi
fi
fi
}