forked from DevShaft/Backup-TA
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackup-TA.bash
executable file
·124 lines (102 loc) · 2.58 KB
/
Backup-TA.bash
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
#!/bin/bash
declare -r VERSION=9.11
BASEDIR="$(dirname "$0")"
ADB="$BASEDIR/linux/tools/adb.x86"
#ADB="adb" # Uncomment to use system's ADB
ZIP=zip
UNZIP=unzip
SCRIPTS="$BASEDIR/linux/scripts"
TOOLS="$BASEDIR/tools"
## TODO: Checks for exit codes after pipes aren't meaningful
##############################################
## Function-replacements (labels in Batch)
##############################################
PARTITION_BY_NAME=/dev/block/platform/msm_sdcc.1/by-name/TA
#####################
## Utils
#####################
_dos2unix() {
sed -e 's/\r//'
}
_unix2dos() {
sed -e 's/$/\r/'
}
_pause() {
read -p "Press [Enter] to continue..."
}
#####################
## INITIALIZE
#####################
initialize() {
clear
echo '[ ------------------------------------------------------------ ]'
printf '%-63s]' "[ Backup TA v$VERSION for Sony Xperia"
echo
cat <<-EOF
[ ------------------------------------------------------------ ]
[ Initialization ]
[ ]
[ Make sure that you have USB Debugging enabled, you do ]
[ allow your computer ADB access by accepting its RSA key ]
[ (only needed for Android 4.2.2 or higher) and grant this ]
[ ADB process root permissions through superuser. ]
[ ------------------------------------------------------------ ]
EOF
}
#####################
## DISPOSE
#####################
dispose() {
echo
echo =======================================
echo CLEAN UP
echo =======================================
local partition=
local choiceTextParam=
local choice=
dispose_menu
dispose_backup
dispose_restore
dispose_convert
if [[ -d tmpbak ]]; then
rm -rf tmpbak
fi
dispose_busybox
echo "Killing ADB Daemon..."
$ADB kill-server >/dev/null 2>&1
echo OK
}
trap dispose EXIT
#################################
## Simple-script replacements
#################################
wakeDevice() {
echo "Waiting for USB Debugging..."
$ADB wait-for-device >/dev/null
echo OK
}
#####################
## CHOICE CHECK
#####################
export ADB SCRIPTS TOOLS VERSION
source "$SCRIPTS/license.bash"
source "$SCRIPTS/busybox.bash"
source "$SCRIPTS/root.bash"
source "$SCRIPTS/menu.bash"
source "$SCRIPTS/backup.bash"
source "$SCRIPTS/restore.bash"
source "$SCRIPTS/convert.bash"
cd "$(dirname "$0")"
if [[ ! -d tmpbak ]]; then
mkdir tmpbak
fi
showLicense
initialize
wakeDevice
pushBusyBox
# pushBusyBox temporary replacement
#export BB=/data/local/tmp/busybox-backup-ta
if ! check_hasRoot ; then # root.bash
exit 1
fi
showMenu