-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmenu
executable file
·133 lines (120 loc) · 3.49 KB
/
menu
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
#!/bin/bash
# Odin4 downloader menu by Mohammad Afaneh, afaneh92 @ Github.
# Variables
menu_version="v2.2"
MENU_DIR=`readlink -f .`
# Color
ON_BLUE=`echo -e "\033[44m"` # On Blue
ON_LBLUE=`echo -e "\033[104m"` # On Light Blue
BRED=`echo -e "\033[1;31m"` # Bold Red
BBLUE=`echo -e "\033[1;34m"` # Bold Blue
BGREEN=`echo -e "\033[1;32m"` # Bold Green
UNDER_LINE=`echo -e "\e[4m"` # Text Under Line
STD=`echo -e "\033[0m"` # Text Clear
# Functions
pause(){
read -p "${BRED}$2${STD}Press ${ON_LBLUE}[Enter]${STD} key to $1..." fackEnterKey
}
clear_var(){
bl=""
ap=""
cp=""
csc=""
ums=""
nand_erase="no"
}
reboot_bl(){
echo " - Rebooting into Download mode";
[ ! -z "$(${MENU_DIR}/odin4 -l)" ] && ${MENU_DIR}/odin4 --redownload || adb reboot download
pause 'continue'
}
reboot_nl(){
echo " - Rebooting into Normal mode";
[ ! -z "$(${MENU_DIR}/odin4 -l)" ] && ${MENU_DIR}/odin4 --reboot
pause 'continue'
}
flash_tar(){
[ ! -z "$bl" ] && bl_arg="-b $bl" || bl_arg=""
[ ! -z "$ap" ] && ap_arg="-a $ap" || ap_arg=""
[ ! -z "$cp" ] && cp_arg="-c $cp" || cp_arg=""
[ ! -z "$csc" ] && csc_arg="-s $csc" || csc_arg=""
[ ! -z "$ums" ] && ums_arg="-u $ums" || ums_arg=""
[ "$nand_erase" == "yes" ] && nand_erase_arg="-e" || nand_erase_arg=""
[ ! -z "$(${MENU_DIR}/odin4 -l)" ] && device_path="-d $(${MENU_DIR}/odin4 -l)"
${MENU_DIR}/odin4 $bl_arg $ap_arg $cp_arg $csc_arg $ums_arg $nand_erase_arg $device_path
pause 'continue'
}
choose_tar(){
find_tar=""
find_tar=($(ls *.tar *.tar.md5 2>/dev/null))
declare -i i=1
shift 2
for e in "${find_tar[@]}"; do
echo "$i) $e"
i=i+1
done
echo ""
read -p "Select: " REPLY
i="$REPLY"
if [[ $i -gt 0 && $i -le ${#find_tar[@]} ]]; then
eval "export ${1}=${find_tar[$i-1]}"
else
pause 'return to Main menu' 'Invalid option!, '
fi
}
# Run once
clear_var
# Show menu
show_menus(){
clear
echo "${ON_BLUE} Odin4 downloader menu $menu_version ${STD}"
echo " "
echo "${BGREEN}ID:COM:${STD} ${ON_BLUE}$(${MENU_DIR}/odin4 -l)${STD}"
echo "${BGREEN}Files [Download]:${STD}"
echo "1. ${UNDER_LINE}B${STD}L ${ON_BLUE}$bl${STD}"
echo "2. ${UNDER_LINE}A${STD}P ${ON_BLUE}$ap${STD}"
echo "3. ${UNDER_LINE}C${STD}P ${ON_BLUE}$cp${STD}"
echo "4. C${UNDER_LINE}S${STD}C ${ON_BLUE}$csc${STD}"
echo "5. ${UNDER_LINE}U${STD}MS ${ON_BLUE}$ums${STD}"
echo " "
echo "${BGREEN}Reboot mode:${STD}"
echo "6. Reboot into ${UNDER_LINE}D${STD}ownload mode"
echo "7. Reboot into ${UNDER_LINE}N${STD}ormal mode"
echo " "
echo "${BGREEN}Nand Erase:${STD} ${ON_BLUE}$nand_erase${STD}"
echo "8. Set/Unset Nand ${UNDER_LINE}e${STD}rase option"
echo " "
echo "${BGREEN}Options:${STD}"
echo "9. S${UNDER_LINE}t${STD}art"
echo "10. ${UNDER_LINE}R${STD}eset"
echo "11. re${UNDER_LINE}f${STD}resh menu"
echo "12. E${UNDER_LINE}x${STD}it"
}
# Read input
read_options(){
local choice
read -p "Enter choice [ 1 - 12 ]: " choice
case $choice in
1|b|B) choose_tar bl ;;
2|a|A) choose_tar ap ;;
3|c|C) choose_tar cp ;;
4|s|S) choose_tar csc ;;
5|u|U) choose_tar ums ;;
6|d|D) reboot_bl ;;
7|n|N) reboot_nl ;;
8|e|E) [ "$nand_erase" == "yes" ] && nand_erase="no" || nand_erase="yes" ;;
9|t|T) flash_tar ;;
10|r|R) clear_var ;;
11|f|F) show_menus ;;
12|x|X) exit 0 ;;
*) pause 'return to Main menu' 'Invalid option, '
esac
}
# Trap CTRL+C, CTRL+Z and quit singles
trap '' SIGINT SIGQUIT SIGTSTP
# Step # Main logic - infinite loop
while true
do
show_menus
read_options
done