forked from RetroFlag/retroflag-picase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
64 lines (47 loc) · 1.64 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
#!/bin/bash
SourcePath=https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master
#Check if root--------------------------------------
if [[ $EUID -ne 0 ]]; then
echo "Please execute script as root."
exit 1
fi
#-----------------------------------------------------------
#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
#-----------------------------------------------------------
#Download Python script-----------------------------
sudo mkdir "/opt/RetroFlag"
script=/opt/RetroFlag/SafeShutdown.py
wget -O $script "$SourcePath/SafeShutdown.py"
#Enable Python script to run on start up------------
RC=/etc/rc.local
if grep -q "sudo python $script &" "$RC";
then
echo "File $RC already configured. Doing nothing."
else
sed -i -e "s/^exit 0/sudo python \/opt\/RetroFlag\/SafeShutdown.py \&\n&/g" "$RC"
echo "File /etc/rc.local configured."
fi
#-----------------------------------------------------------
#Reboot to apply changes----------------------------
echo "RetroFlag Pi Case installation done. Will now reboot after 3 seconds."
sleep 3
sudo reboot
#-----------------------------------------------------------