forked from spiritualized/retroflag-picase-libreelec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
71 lines (52 loc) · 1.82 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
#!/bin/bash
#Step 1) Check if root--------------------------------------
if [[ $EUID -ne 0 ]]; then
echo "Please execute script as root."
exit 1
fi
#-----------------------------------------------------------
#Step 2) enable UART----------------------------------------
cd /boot/
File=config.txt
if grep -q "enable_uart=1" "$File";
then
echo "UART already enabled. Doing nothing."
else
echo "enable_uart=1" >> $File
echo "UART enabled."
fi
#-----------------------------------------------------------
#Step 3) Update repository----------------------------------
sudo apt-get update -y
#-----------------------------------------------------------
#Step 4) Install gpiozero module----------------------------
sudo apt-get install -y python3-gpiozero
#-----------------------------------------------------------
#Step 5) Download Python script-----------------------------
cd /opt/
sudo mkdir RetroFlag
cd /opt/RetroFlag
script=SafeShutdown.py
if [ -e $script ];
then
echo "Script SafeShutdown.py already exists. Doing nothing."
else
wget "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/SafeShutdown.py"
fi
#-----------------------------------------------------------
#Step 6) Enable Python script to run on start up------------
cd /etc/
RC=rc.local
if grep -q "sudo python3 \/opt\/RetroFlag\/SafeShutdown.py \&" "$RC";
then
echo "File /etc/rc.local already configured. Doing nothing."
else
sed -i -e "s/^exit 0/sudo python3 \/opt\/RetroFlag\/SafeShutdown.py \&\n&/g" "$RC"
echo "File /etc/rc.local configured."
fi
#-----------------------------------------------------------
#Step 7) Reboot to apply changes----------------------------
echo "RetroFlag Pi Case installation done. Will now reboot after 3 seconds."
sleep 3
sudo reboot
#-----------------------------------------------------------