-
Notifications
You must be signed in to change notification settings - Fork 16
/
startup.sh
executable file
·70 lines (66 loc) · 1.65 KB
/
startup.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
#!/bin/sh
cat << EOF
#
Starting piRa1n
#
$(cat /home/pi/piRa1n/piRa1n.conf)
#
EOF
. /home/pi/piRa1n/piRa1n.conf
checkra1n() {
echo "Starting checkra1n"
[ "$Safe_Mode" = true ] && export CHECKRA1N_SAFE_MODE=1
[ "$Verbose_Boot" = true ] && export CHECKRA1N_VERBOSE_BOOT=1
/home/pi/piRa1n/checkra1n -c -E
}
shutDownPi() {
echo "Shutting down"
/sbin/shutdown now
}
if [ "$Auto_Recovery_Mode" = false ]; then
# Auto_Recovery_Mode = false
if [ "$Auto_Shutdown" = false ]; then
# Auto_Shutdown = false
while true; do
checkra1n
echo "Waiting for the next iDevice..."
done
else
# Auto_Shutdown = true
checkra1n
shutDownPi
fi
else
# Auto_Recovery_Mode = true
echo "Waiting for an iDevice..."
while true; do
# Enter recovery mode if iDevice is connected
if idevice_id -l > /dev/null 2>&1 && [ -n "$(idevice_id -l)" ]; then
echo "Entering recovery mode..."
ideviceenterrecovery "$(idevice_id -l)"
sleep 4
# Check if iDevice is in recovery mode
elif lsusb | grep -q 'Recovery'; then
if [ "$idevice_recovery_mode" != '1' ]; then
idevice_recovery_mode='1'
echo "iDevice is in recovery mode."
/usr/local/bin/irecovery -c 'setenv auto-boot true'
/usr/local/bin/irecovery -c 'saveenv'
fi
sleep 16
# Check if iDevice is in DFU mode
elif lsusb | grep -q 'DFU'; then
echo "iDevice is in DFU mode."
checkra1n
if [ "$Auto_Shutdown" = false ]; then
# Auto_Shutdown = false
echo "Waiting for the next iDevice..."
else
# Auto_Shutdown = true
shutDownPi
fi
else
sleep 1
fi
done
fi