-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
92 lines (70 loc) · 2.33 KB
/
install.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
# x708 powering on /reboot / full shutdown through hardware
#!/bin/bash
echo '#!/bin/bash
SHUTDOWN=5
REBOOTPULSEMINIMUM=200
REBOOTPULSEMAXIMUM=600
echo "$SHUTDOWN" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$SHUTDOWN/direction
BOOT=12
echo "$BOOT" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$BOOT/direction
echo "1" > /sys/class/gpio/gpio$BOOT/value
x708_timer_restart(){
while [ 1 ]; do
/bin/sleep 50
sudo /usr/local/bin/x708softsd.sh
done
}
while [ 1 ]; do
shutdownSignal=$(cat /sys/class/gpio/gpio$SHUTDOWN/value)
if [ $shutdownSignal = 0 ]; then
/bin/sleep 0.2
else
pulseStart=$(date +%s%3N)
while [ $shutdownSignal = 1 ]; do
/bin/sleep 0.02
if [ $(($(date +%s%3N)-$pulseStart)) -gt $REBOOTPULSEMAXIMUM ]; then
echo "X708 shutting down..."
echo "Shutting down RaspiBlitz..."
x708_timer_restart &
sudo /home/admin/config.scripts/blitz.shutdown.sh
exit
fi
shutdownSignal=$(cat /sys/class/gpio/gpio$SHUTDOWN/value)
done
if [ $(($(date +%s%3N)-$pulseStart)) -gt $REBOOTPULSEMINIMUM ]; then
echo "X708 rebooting..."
echo "Rebooting RaspiBlitz..."
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit
fi
fi
done' > /etc/x708pwr.sh
sudo chmod +x /etc/x708pwr.sh
sudo sed -i '$ i /etc/x708pwr.sh &' /etc/rc.local
# X708 full shutdown through "x708off" command
#!/bin/bash
echo '#!/bin/bash
BUTTON=13
echo "$BUTTON" > /sys/class/gpio/export;
echo "out" > /sys/class/gpio/gpio$BUTTON/direction
echo "1" > /sys/class/gpio/gpio$BUTTON/value
SLEEP=${1:-4}
re='^[0-9\.]+$'
if ! [[ $SLEEP =~ $re ]] ; then
echo "error: sleep time not a number" >&2; exit 1
fi
echo "X708 shutting down..."
/bin/sleep $SLEEP
echo "0" > /sys/class/gpio/gpio$BUTTON/value
' > /usr/local/bin/x708softsd.sh
sudo chmod +x /usr/local/bin/x708softsd.sh
printf "%s\n" "alias x708off='sudo x708softsd.sh'" >> /home/admin/.bash_aliases
# X708 info and auto shutdown script
sudo chmod +x /home/admin/x708blitz/x708.info.py
# X708 fan control python script
sudo chmod +x /home/admin/x708blitz/x708.fan.py
sudo sed -i '$ i python3 /home/admin/x708blitz/x708.fan.py &' /etc/rc.local
#Change OFF entry in RaspiBlitz main menu to perform X708 shutdown
patch -u -b /home/admin/00mainMenu.sh -i /home/admin/x708blitz/00mainMenu.sh.diff