-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_update.sh
237 lines (196 loc) · 8.75 KB
/
run_update.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/sh
NONE='\033[00m'
RED='\033[01;31m'
GREEN='\033[01;32m'
YELLOW='\033[01;33m'
PURPLE='\033[01;35m'
CYAN='\033[01;36m'
WHITE='\033[01;37m'
BOLD='\033[1m'
UNDERLINE='\033[4m'
BLINK='\x1b[5m'
clear
echo "### Update started - Log cleaned up " &>> ~/storage/shared/pegasus_installer_log.log
FILE=~/dragoonDoriseTools/.device
if [ -f "$FILE" ]; then
echo ""
else
while true; do
export NEWT_COLORS="
root=,red
roottext=yellow,red"
handheldModel=$(whiptail --title "What Android Device do you have" \
--radiolist "Move using your DPAD and select your platforms with the Y button. Press the A button to select." 10 80 4 \
"RG552" "Anbernic RG552" OFF \
"ODIN" "AYN Odin" OFF \
"RP2+" "Retroid Pocket 2+" OFF \
"ANDROID" "A regular Android Device" OFF \
3>&1 1<&2 2>&3)
case $handheldModel in
[RG552]* ) break;;
[ODIN]* ) break;;
[RP2+]* ) break;;
[ANDROID]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
echo $handheldModel > ~/dragoonDoriseTools/.device
fi
#Handheld detector
handheldModel=$(cat ~/dragoonDoriseTools/.device)
useInternalStorage=false
FILE=~/dragoonDoriseTools/.storageInternal
if [ -f "$FILE" ]; then
useInternalStorage=true
storageLocation="shared/roms"
else
useInternalStorage=false
storageLocation="external-1"
fi
cat ~/dragoonDoriseTools/pegasus-android-metadata/logo.ans
version=$(cat ~/dragoonDoriseTools/pegasus-android-metadata/version.md)
#Detect installed emulators
hasRetroArch64=false
#Retroarch 64?
FOLDER64=~/storage/shared/Android/data/com.retroarch.aarch64
if [ -d "$FOLDER64" ]; then
hasRetroArch64=true
fi
#update scripts
echo -ne "Updating Scripts..."
pkg install git wget jq rsync unzip whiptail binutils build-essential liblz4 libuv ninja -y &>> ~/storage/shared/pegasus_installer_log.log
echo "/bin/bash ~/startup.sh" > ~/.bashrc
echo -e "${GREEN}OK${NONE}"
echo "### Updating scripts " &>> ~/storage/shared/pegasus_installer_log.log
echo -ne "Updating Bundled Themes (won't affect any other themes)..."
FOLDER=~/storage/shared/pegasus-frontend/themes/RP-epic-noir
if [ -d "$FOLDER" ]; then
cd ~/dragoonDoriseTools/themes/RP-epic-noir
git reset --hard &>> ~/storage/shared/pegasus_installer_log.log
git pull &>> ~/storage/shared/pegasus_installer_log.log
else
echo -ne "Downloading Pegasus Theme : RP Epic Noir..."
git clone https://github.com/dragoonDorise/RP-epic-noir.git ~/dragoonDoriseTools/themes/RP-epic-noir &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
fi
FOLDER=~/storage/shared/pegasus-frontend/themes/RP-switch
if [ -d "$FOLDER" ]; then
cd ~/dragoonDoriseTools/themes/RP-switch
git reset --hard &>> ~/storage/shared/pegasus_installer_log.log
git pull &>> ~/storage/shared/pegasus_installer_log.log
else
echo -ne "Downloading Pegasus Theme : RP Switch..."
#We delete the theme, for previous users
rm -rf ~/storage/shared/pegasus-frontend/themes/RP-switch &>> ~/storage/shared/pegasus_installer_log.log
git clone https://github.com/dragoonDorise/RP-switch.git ~/dragoonDoriseTools/themes/RP-switch &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
fi
FOLDER=~/storage/shared/pegasus-frontend/themes/retromega
if [ -d "$FOLDER" ]; then
cd ~/dragoonDoriseTools/themes/retromega
git reset --hard &>> ~/storage/shared/pegasus_installer_log.log
git pull &>> ~/storage/shared/pegasus_installer_log.log
else
echo -ne "Downloading Pegasus Theme : Retro Mega..."
git clone https://github.com/plaidman/retromega-next.git ~/dragoonDoriseTools/themes/retromega &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
fi
if [ $handheldModel != 'RP2+' ]; then
FOLDER=~/storage/shared/pegasus-frontend/themes/gameOS
if [ -d "$FOLDER" ]; then
cd ~/dragoonDoriseTools/themes/gameOS
git reset --hard &>> ~/storage/shared/pegasus_installer_log.log
git pull &>> ~/storage/shared/pegasus_installer_log.log
else
echo -ne "Downloading Pegasus Theme : GameOS..."
git clone https://github.com/PlayingKarrde/gameOS.git ~/dragoonDoriseTools/themes/gameOS &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
fi
FOLDER=~/storage/shared/pegasus-frontend/themes/clearOS
if [ -d "$FOLDER" ]; then
cd ~/dragoonDoriseTools/themes/clearOS
git reset --hard &>> ~/storage/shared/pegasus_installer_log.log
git pull &>> ~/storage/shared/pegasus_installer_log.log
else
echo -ne "Downloading Pegasus Theme : ClearOS..."
git clone https://github.com/PlayingKarrde/clearOS.git ~/dragoonDoriseTools/themes/clearOS &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
fi
FOLDER=~/storage/shared/pegasus-frontend/themes/neoretro-dark
if [ -d "$FOLDER" ]; then
cd ~/dragoonDoriseTools/themes/neoretro-dark
git reset --hard &>> ~/storage/shared/pegasus_installer_log.log
git pull &>> ~/storage/shared/pegasus_installer_log.log
else
echo -ne "Downloading Pegasus Theme : NeoRetro Dark..."
git clone https://github.com/TigraTT-Driver/neoretro-dark.git ~/dragoonDoriseTools/themes/neoretro-dark &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
fi
echo "### Themes updated " &>> ~/storage/shared/pegasus_installer_log.log
fi
echo "### Rsync the dl themes " &>> ~/storage/shared/pegasus_installer_log.log
rsync -r ~/dragoonDoriseTools/themes/ ~/storage/shared/pegasus-frontend/themes/ &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${GREEN}OK${NONE}"
#Metadata update
echo "### Updating Rom folders " &>> ~/storage/shared/pegasus_installer_log.log
echo -ne "Updating Metadata..."
rsync -r ~/dragoonDoriseTools/pegasus-android-metadata/roms/ ~/storage/$storageLocation &>> ~/storage/shared/pegasus_installer_log.log
echo "### Rom folders updated " &>> ~/storage/shared/pegasus_installer_log.log
#Retroarch64 support
if [ $hasRetroArch64 == true ]; then
find ~/storage/$storageLocation/ -type f -name "*.txt" -exec sed -i -e 's/com.retroarch\//com.retroarch.aarch64\//g' {} \;
find ~/storage/$storageLocation/ -type f -name "*.txt" -exec sed -i -e 's/-e DATADIR \/data\/data\/com.retroarch/-e DATADIR \/data\/data\/com.retroarch.aarch64/g' {} \;
find ~/storage/$storageLocation/ -type f -name "*.txt" -exec sed -i -e 's/.browser.retroactivity/com.retroarch.browser.retroactivity/g' {} \;
find ~/storage/$storageLocation/ -type f -name "*.txt" -exec sed -i -e 's/com.retroarch-1/com.retroarch.aarch64-1/g' {} \;
echo "### RA64 sed" &>> ~/storage/shared/pegasus_installer_log.log
fi
#cp ~/dragoonDoriseTools/pegasus-android-metadata/internal/common/pegasus-frontend/settings.txt ~/storage/shared/pegasus-frontend &>> ~/storage/shared/pegasus_installer_log.log
cp ~/dragoonDoriseTools/pegasus-android-metadata/internal/common/pegasus-frontend/game_dirs.txt ~/storage/shared/pegasus-frontend &>> ~/storage/shared/pegasus_installer_log.log
if [ $useInternalStorage == false ]; then
#We get the SD Card Volume name
for entry in /storage/*
do
STR=$entry
SUB='-'
if grep -q "$SUB" <<< "$STR"; then
firstString=$entry
secondString=""
sdcardID="${firstString/"/storage/"/"$secondString"}"
fi
done
sed -i "s/0000-0000\//${sdcardID}\/Android\/data\/com.termux\/files\//g" ~/storage/shared/pegasus-frontend/game_dirs.txt &>> ~/storage/shared/pegasus_installer_log.log
else
sed -i "s/0000-0000/emulated\/0\/roms\//g" ~/storage/shared/pegasus-frontend/game_dirs.txt &>> ~/storage/shared/pegasus_installer_log.log
fi
echo -e "${GREEN}OK${NONE}"
echo "### Folder roms Pegasus updated " &>> ~/storage/shared/pegasus_installer_log.log
FILE=~/dragoonDoriseTools/.isRG552
if [ -f "$FILE" ]; then
rm ~/dragoonDoriseTools/.isRG552
touch ~/dragoonDoriseTools/.device
echo 'RG552' > ~/dragoonDoriseTools/.device
fi
#Emulator check
/bin/bash ~/dragoonDoriseTools/pegasus-android-metadata/emu_check.sh
#RetroArch Update
echo -ne "Updating Retroarch Config..."
#RetroArch Configs
/bin/bash ~/dragoonDoriseTools/pegasus-android-metadata/retroarch_config.sh $handheldModel
/bin/bash ~/dragoonDoriseTools/pegasus-android-metadata/emus_config.sh
newVersion=$(cat ~/dragoonDoriseTools/pegasus-android-metadata/version.md)
echo ""
echo -e "${GREEN}Update Completed${NONE}"
echo ""
echo -e "${YELLOW}Changelog${NONE}"
cat ~/dragoonDoriseTools/pegasus-android-metadata/changelog.md
echo ""
echo -e "Your version was: ${PURPLE}$version${NONE}"
echo -e "Installed version is now: ${GREEN}$newVersion${NONE}"
echo -e ""
echo "### Updated completed" &>> ~/storage/shared/pegasus_installer_log.log
echo -e "${YELLOW}REMEMBER TO INSTALL CORES${NONE} If you downloaded new cores.."
echo -e "Go to Retroarch's Main Menu -> Load Core -> Install or Restore a Core"
echo -e "And just select the core you want to install"
echo -e "Press the ${RED}A button${NONE} to finish"
read pause
am startservice -a com.termux.service_stop com.termux/.app.TermuxService &> /dev/null