Skip to content

Commit a0e9187

Browse files
1. flash_all_except_*.sh file bug fix
2. Feature added
1 parent 819ebd1 commit a0e9187

File tree

3 files changed

+71
-16
lines changed

3 files changed

+71
-16
lines changed

.DS_Store

0 Bytes
Binary file not shown.

flash-stock-rom.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ if [ ! -f $file2 ]; then
2424
exit 1;
2525
fi
2626

27-
if [ ! -f $file3 ]; then
28-
echo -e "\033[0;31m $file3 file is not found \033[0m";
29-
exit 1;
30-
fi
31-
3227

3328
if ! grep -q "$replace" "$file1"; then
3429
awk '{ gsub(/'"$look"'/, "'"$replace"'"); print }' "$file1" > flash_all.txt && mv flash_all.txt "$file1"
@@ -41,11 +36,24 @@ if ! grep -q "$replace" "$file2"; then
4136

4237
awk -v search="/images/" -v replace="/stock-rom/images/" '{ gsub(search, replace); print }' "$file2" > flash_all.txt && mv flash_all.txt "$file2"
4338
fi
44-
if ! grep -q "$replace" "$file3"; then
45-
awk '{ gsub(/'"$look"'/, "'"$replace"'"); print }' "$file3" > flash_all_except_data_storage.txt && mv flash_all_except_data_storage.txt "$file3"
4639

47-
awk -v search="/images/" -v replace="/stock-rom/images/" '{ gsub(search, replace); print }' "$file3" > flash_all.txt && mv flash_all.txt "$file3"
48-
fi
40+
# Use a loop to handle multiple files that match the pattern
41+
for file in ./stock-rom/flash_all_except_*.sh; do
42+
if [[ -f "$file" ]]; then
43+
echo "Processing file: $file"
44+
45+
if ! grep -q "$replace" "$file"; then
46+
# Replace 'look' with 'replace' in the file
47+
awk '{ gsub(/'"$look"'/, "'"$replace"'"); print }' "$file" > flash_all.txt && mv flash_all.txt "$file"
48+
49+
# Replace '/images/' with '/stock-rom/images/' in the file
50+
awk -v search="/images/" -v replace="/stock-rom/images/" '{ gsub(search, replace); print }' "$file" > flash_all.txt && mv flash_all.txt "$file"
51+
fi
52+
else
53+
echo "No files found matching the pattern."
54+
fi
55+
done
56+
4957

5058
if [ $? -eq 0 ]; then
5159
echo -e "\033[0;32m Modifying Flash file Succeed!

flash.sh

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ What do you want to do?
66
1. Flash Recovery
77
2. Flash VBMETA
88
3. Use adb Sideload
9-
4. Check adb devices
10-
5. Check fastboot devices
11-
6. Reboot to System
12-
7. Flash MIUI Stock ROM (Fastboot)
9+
4. Use adb Sideload and Reboot to recovery
10+
5. Check adb devices
11+
6. Check fastboot devices
12+
7. Reboot to System
13+
8. Reboot to Recovery
14+
9. Reboot to Bootloader
15+
10. Reboot to Fastboot
16+
11. Flash MIUI Stock ROM (Fastboot)
1317
(Press Any key to Exit or input your choice.)
1418
\033[0m";
1519

@@ -108,24 +112,67 @@ case $flasher in
108112

109113
;;
110114
"4")
115+
116+
echo -e "\033[0;32m Please enter the file name of your custom rom. \033[0m";
117+
read -p "Enter the zip file name: " romname
118+
119+
if [ ! -f "$romname" ]; then
120+
echo -e "\033[0;31m > $romname file is not found \033[0m";
121+
echo -e "\033[0;31m \033[3m Please ensure that '$romname' file exist and try again. Have a good day! \033[0m";
122+
exit 1;
123+
fi
124+
if [ ! -f "./platform-tools/adb" ]; then
125+
echo -e "\033[0;31m > adb file is not found \033[0m";
126+
echo -e "\033[0;31m \033[3m Please ensure that 'adb' file exist and try again. Have a good day! \033[0m";
127+
exit 1;
128+
fi
129+
./platform-tools/adb sideload $romname
130+
131+
if [ $? -eq 0 ]; then
132+
echo -e "\033[0;32m Sideload operation completed. Rebooting to Recovery \033[0m";
133+
./platform-tools/adb reboot recovery
134+
fi
135+
136+
source ./flash.sh
137+
138+
;;
139+
"5")
111140
echo -e "\033[0;32m adb device list: \033[0m"
112141
./platform-tools/adb devices
113142

114143
source ./flash.sh
115144
;;
116-
"5")
145+
"6")
117146
echo -e "\033[0;32m fastboot device list: \033[0m"
118147
./platform-tools/fastboot devices
119148

120149
source ./flash.sh
121150
;;
122-
"6")
151+
"7")
123152
echo -e "\033[0;32m Rebooting your device to system! Have a good day! \033[0m";
124153
./platform-tools/fastboot reboot
125154

126155
source ./flash.sh
127156
;;
128-
"7")
157+
"8")
158+
echo -e "\033[0;32m Rebooting your device to Recovery! \033[0m";
159+
./platform-tools/fastboot reboot recovery
160+
161+
source ./flash.sh
162+
;;
163+
"9")
164+
echo -e "\033[0;32m Rebooting your device to Bootloader! \033[0m";
165+
./platform-tools/fastboot reboot bootloader
166+
167+
source ./flash.sh
168+
;;
169+
"10")
170+
echo -e "\033[0;32m Rebooting your device to Fastboot! \033[0m";
171+
./platform-tools/fastboot reboot fastboot
172+
173+
source ./flash.sh
174+
;;
175+
"11")
129176
echo -e "\033[0;32m Great Choice! Heading up to Stock ROM Flash system! \033[0m";
130177
source ./flash-stock-rom.sh;
131178
;;

0 commit comments

Comments
 (0)