Last active
June 21, 2021 17:55
-
-
Save Nanolx/53690c06e86bac1329e0893192a4d38c to your computer and use it in GitHub Desktop.
flash script (OnePlus 7T tested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
indir=${PWD} | |
clean_preinstall () { | |
for part in system system_ext odm product vendor; do | |
fastboot erase ${part} | |
done | |
} | |
clean_postinstall () { | |
for part in userdata metadata; do | |
fastboot erase ${part} | |
done | |
} | |
flash_rom () { | |
for img in boot dtbo odm product system system_ext \ | |
vbmeta vbmeta_system vendor; do | |
if [ ! -f "${indir}/${img}.img" ]; then | |
echo "XXX image ${indir}/${img}.img not found!" | |
exit 1 | |
fi | |
done | |
for img in boot dtbo odm product system system_ext \ | |
vbmeta vbmeta_system vendor; do | |
fastboot flash ${img} "${indir}/${img}.img" | |
done | |
} | |
_help () { | |
echo -e "\n+++ flash script +++ | |
syntax: flash.sh {action} [input directory] | |
where action can be one of | |
u | update | -u update the ROM | |
c | clean | -c clean flash the ROM | |
NOTE: ERASES ALL DATA! | |
r | recovery | -r flash recovery only | |
[input directory] is optionally the directory containing | |
the files, current working directory if not given. | |
" | |
} | |
[ -d "${2}" ] && indir="${2}" | |
case ${1} in | |
u | update | -u ) | |
flash_rom | |
fastboot reboot | |
;; | |
c | clean | -c ) | |
clean_preinstall | |
flash_rom | |
clean_postinstall | |
fastboot reboot | |
;; | |
r | recovery | -r ) | |
if [ -f "${indir}/recovery.img" ]; then | |
fastboot flash recovery "${indir}/recovery.img" | |
fastboot reboot recovery | |
else | |
echo "XXX image ${indir}/recovery.img not found!" | |
fi | |
;; | |
* ) | |
_help | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment