forked from RetroFlag/retroflag-picase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batocera_install.sh
72 lines (61 loc) · 1.92 KB
/
batocera_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
#!/bin/bash
SourcePath=https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master
#-----------------------------------------------------------
sleep 2s
mount -o remount, rw /boot
mount -o remount, rw /
#RetroFlag pw io ;2:in ;3:in ;4:in ;14:out 1----------------------------------------
File=/boot/config.txt
wget -O "/boot/overlays/RetroFlag_pw_io.dtbo" "$SourcePath/RetroFlag_pw_io.dtbo"
if grep -q "RetroFlag_pw_io" "$File";
then
sed -i '/RetroFlag_pw_io/c dtoverlay=RetroFlag_pw_io.dtbo' $File
echo "PW IO fix."
else
echo "dtoverlay=RetroFlag_pw_io.dtbo" >> $File
echo "PW IO enabled."
fi
if grep -q "enable_uart" "$File";
then
sed -i '/enable_uart/c enable_uart=1' $File
echo "UART fix."
else
echo "enable_uart=1" >> $File
echo "UART enabled."
fi
#-----------------------------------------------------------
sleep 2s
if grep -q "system.power.switch" "/userdata/system/batocera.conf";
then
sed -i '/system.power.switch/c system.power.switch=RETROFLAG' "/userdata/system/batocera.conf"
echo "power switch fix."
else
echo "system.power.switch=RETROFLAG" >> /userdata/system/batocera.conf
echo "power switch enabled."
fi
#-----------------------------------------------------------
mkdir /userdata/RetroFlag
sleep 2s
script=/userdata/RetroFlag/SafeShutdown.py
wget -O $script "$SourcePath/batocera_SafeShutdown.py"
#-----------------------------------------------------------
sleep 2s
DIR=/userdata/system/custom.sh
if grep -q "python $script &" "$DIR";
then
if [ -x "$DIR" ];
then
echo "Executable script already configured. Doing nothing."
else
chmod +x $DIR
fi
else
echo "python $script &" >> $DIR
chmod +x $DIR
echo "Executable script configured."
fi
#-----------------------------------------------------------
echo "RetroFlag Pi Case Switch installation done. Will now reboot after 3 seconds."
sleep 3
shutdown -r now
#-----------------------------------------------------------