-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautostart_install.sh
150 lines (127 loc) · 3.61 KB
/
autostart_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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
######################################################################################################
##
## Installer for "Sinden Lightgun Autostart"
## -- by Widge
## February 2023
##
######################################################################################################
thisfile=$(echo "$PWD/"`basename "$0"`)
branch="ver1"
repo="https://github.com/Widge-5/Sinden_Lightgun_Autostart/archive/refs/heads/"$branch".zip"
tmpfolder="/home/pi/slgce_install"
destfolder="/home/pi/Lightgun/utils"
sindenfolder="/home/pi/RetroPie/roms"
utilscfg="widgeutils.cfg"
title="Sinden Lightgun Autostart"
automode=false
function rootcheck() {
#- Script must be run as root
if [[ $EUID > 0 ]]; then
colourecho cLRED "ERROR: Script must be run as root: eg: \"sudo $thisfile\""
exit 0
else
return
fi
}
function colourecho(){
_nc="\033[0m"
case $1 in
cBLACK ) _col="\033[0;30m";;
cDGRAY|cDGREY ) _col="\033[1;30m";;
cRED ) _col="\033[0;31m";;
cLRED ) _col="\033[1;31m";;
cGREEN ) _col="\033[0;32m";;
cLGREEN ) _col="\033[1;32m";;
cBROWN|cORANGE ) _col="\033[0;33m";;
cYELLOW ) _col="\033[1;33m";;
cBLUE ) _col="\033[0;34m";;
cLBLUE ) _col="\033[1;34m";;
cPURPLE ) _col="\033[0;35m";;
cLPURPLE ) _col="\033[1;35m";;
cCYAN ) _col="\033[0;36m";;
cLCYAN ) _col="\033[1;36m";;
cLGRAY|cLGREY ) _col="\033[0;37m";;
cWHITE ) _col="\033[1;37m";;
cNUL|* ) _col=$nc;;
esac
echo -e "${_col}${2}${_nc}"
}
function downloader() {
rm -rf $2
mkdir $2
cd $2
echo "Downloading "$1"..."
wget --timeout 15 --no-http-keep-alive --no-cache --no-cookies $3
wait
echo "Extracting "$1"..."
unzip -q $branch".zip"
}
function tidyup(){
echo "Cleaning up...."
cd /home/pi
rm -rf $1
echo "Done."
}
function main() {
echo $thisfile
while true ; do
colourecho cLCYAN "In which location are your Sinden start scripts?"
colourecho cLGREEN "[1] SINDEN"
colourecho cLGREEN "[2] PORTS"
colourecho cLGREEN "[Q] quit"
if [ $automode = true ]; then
ans=1
else
read -N1 ans
fi
case "$ans" in
1) colourecho cLBLUE " : SINDEN"
sindenfolder="$sindenfolder/sinden"
break ;;
2) colourecho cLBLUE " : PORTS"
sindenfolder="$sindenfolder/ports"
break ;;
Q|q) colourecho cLRED " : CANCELLING"
exit;;
esac
done
downloader "Autostart for Sinden Lightgun" "$tmpfolder" "$repo"
cd "$tmpfolder/Sinden_Lightgun_Autostart-"$branch
chmod +x *.sh
if [ ! -d "$destfolder" ]; then
mkdir "$destfolder"
fi
cp -pf "$tmpfolder/Sinden_Lightgun_Autostart-"$branch"/sindenautostart.sh" $destfolder
cp -pf "$tmpfolder/Sinden_Lightgun_Autostart-"$branch"/Sinden Lightgun Autostart Options.sh" $sindenfolder
tidyup "$tmpfolder"
chown -R pi:pi "$destfolder"
colourecho cLCYAN "Install completed"
while true ; do
colourecho cLCYAN "Do you want to delete this installer?"
colourecho cLGREEN "[Y] Yes"
colourecho cLGREEN "[N] No"
if [ $automode = true ]; then
ans="Y"
else
read -N1 ans
fi
case "$ans" in
y|Y) colourecho cLBLUE " : YES"
/bin/rm -f "$thisfile"
break ;;
n|N) colourecho cLBLUE " : NO"
break ;;
esac
done
colourecho cLRED "Now restart EmulationStation"
}
####### START #######
rootcheck
if [ "$1" = "--auto" -o "$1" = "-a" ]; then
automode=true
echo "Automatic installation requested..."
else
automode=false
fi
main