#!/usr/bin/env bash echo "ADB TWRP" if [ -f /usr/bin/adb ]; then echo "Searching for devices..." adb devices | grep "recovery" &> /dev/null if [ $? -eq 0 ]; then echo "Device found." read -n 1 -s -r -p "Press any key to continue" else echo "Devices not found." #exit 0 fi else echo "Dependency adb not installed." exit 0 fi . tools/menu.sh . tools/filemanager.sh . tools/helper.sh function push_install { local filename=$1 local path="$(pwd)/${filename}" adb push "${path}" '/sdcard' adb shell "twrp install /sdcard/${filename}" } function install_zip { clear echo " █ █▄░█ █▀ ▀█▀ ▄▀█ █░░ █░░   ▀█ █ █▀█ █ █░▀█ ▄█ ░█░ █▀█ █▄▄ █▄▄   █▄ █ █▀▀ " select_option "Enter absolute path." "Navigate and choose file" case $? in 0) read -p "Enter absolute path of the zip file: " zipfile if [ -f $zipfile ]; then checkzip "$zipfile" fi if [ $? -eq 0 ];then a=($(echo $zipfile | tr "/" " ")) count=${#a[@]} filename=${a[count-1]} path='' for ((i=0; i < count-1; i++));do path+="/${a[i]}" done adb push "${path}/${filename}" '/sdcard' adb shell "twrp install /sdcard/${filename}" else echo "File not found!" fi;; 1) filemanager;; esac read -n 1 -s -r -p "Press any key to continue" main } function wipes { clear echo " █░█░█ █ █▀█ █▀▀ ▀▄▀▄▀ █ █▀▀ ██▄ " wipes_part=("Dalvik/ART cache" "System" "Cache" "Data" "Wipe" "Exit") #"Vendor" multi_select_option "${wipes_part[@]}" if [[ $? -eq 0 ]];then for ((i=0; i < ${#choices[@]}; i++)); do if [[ "${choices[$i]}" == "*" ]]; then case ${wipes_part[${i}]} in "Dalvik/ART cache") adb shell "twrp wipe dalvik";; "System") adb shell "twrp wipe system";; "Vendor") adb shell "twrp wipe vendor";; "Cache") adb shell "twrp wipe cache";; "Data") adb shell "twrp wipe data";; esac fi done read -n 1 -s -r -p "Press any key to continue" fi } function format_data { clear echo " █▀▀ █▀█ █▀█ █▀▄▀█ ▄▀█ ▀█▀   █▀▄ ▄▀█ ▀█▀ ▄▀█ █▀░ █▄█ █▀▄ █░▀░█ █▀█ ░█░   █▄▀ █▀█ ░█░ █▀█ " confirm_question "Format Data" if [[ $? -eq 0 ]]; then adb shell "twrp format data" read -n 1 -s -r -p "Press any key to continue" main else main fi } function data_decrypt { read -rsp "Enter password from Decrypt /Data " passwd adb shell "twrp decrypt ${passwd}" read -n 1 -s -r -p "Press any key to continue" } function reboot_select { clear echo " █▀█ █▀▀ █▄▄ █▀█ █▀█ ▀█▀ █▀▄ ██▄ █▄█ █▄█ █▄█ ░█░ " select_option "System" "Recovery" "Poweroff" "BootLoader" "EDL" "Back" case $? in 0) adb shell twrp reboot 1> /dev/null;; # System 1) adb shell twrp reboot recovery;; # Recovery 2) adb shell twrp reboot poweroff;; # PowerOff 3) adb shell twrp reboot bootloader;; # BootLoader 4) adb shell twrp reboot download;; # EDL 5) main;; # back esac read -n 1 -s -r -p "Press any key to continue" main } function main { clear echo " ▀█▀ █░█░█ █▀█ █▀█   █▀▀ █▀█ █▄░█ ▀█▀ █▀█ █▀█ █░░ ░█░ ▀▄▀▄▀ █▀▄ █▀▀   █▄▄ █▄█ █░▀█ ░█░ █▀▄ █▄█ █▄▄ " select_option "Flash zip" "Wipe" "Format Data" "Decrypt /Data" "Reboot" "Exit" case $? in 0) install_zip;; # Flash zip 1) wipes;; # Wipe 2) format_data;; # Format Data 3) data_decrypt;; 4) reboot_select;; # Reboot 5) adb kill-server && clear && exit 0;; esac #read -n 1 -s -r -p "Press any key to continue" main } main