-
Notifications
You must be signed in to change notification settings - Fork 2
/
db-from-app
executable file
·94 lines (86 loc) · 1.99 KB
/
db-from-app
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
#!/bin/bash
# download app data and extract
cd `dirname $0`
# for adb and abe
export PATH=`pwd`/tools:${PATH}
which adb > /dev/null
if [ $? -ne 0 ] ; then
echo no \"adb\" found - install android platform tools
exit 99
fi
which abe > /dev/null
if [ $? -ne 0 ] ; then
echo no \"abe\" \(android backup extractor\) found
exit 99
fi
mkdir -p tmp
# backup data
if [ -s tmp/librelink.ab ]
then
read -p "\"librelink.ab\" already there, remove? (y/N) " x
case $x in
y*|Y*)
rm -f tmp/librelink.ab
;;
*)
;;
esac
fi
if [ -d tmp/apps ]
then
read -p "\"apps/\" already there, remove? (y/N) " x
case $x in
y*|Y*)
rm -rf tmp/apps
;;
*)
;;
esac
fi
if [ ! -s tmp/librelink.ab ] ; then
echo no \"librelink.ab\" backup file found
read -p "read from android device? (y/N) " x
case $x in
y*|Y*)
echo It is recommended to open the LibreLink app in the foreground.
echo
echo Confirm backup without password on Android device next.
echo Caveat: There is a timeout of 60 seconds\!
echo
adb -d backup -f tmp/librelink.ab -noapk com.freestylelibre.app.de
echo
echo Now check that the Librelink app is still running,
echo otherwise restart it \*now\* to avoid data loss\!
echo
;;
*)
;;
esac
else
read -p "\"librelink.ab\" already there, OK? (y/N) " x
case $x in
y*|Y*)
;;
*)
exit 98
;;
esac
fi
if [ ! -s tmp/librelink.ab ] ; then
echo "no meaningful \"librelink.ab\" backup file found - exiting"
exit 98
fi
# extract tar from compressed backup and unpack
# "abe" is renamed "abe.sh" with "abe.jar in same directory
abe \
unpack tmp/librelink.ab tmp/librelink.tar "" && \
LC_ALL=C tar xf tmp/librelink.tar -C tmp/ && \
rm tmp/librelink.ab tmp/librelink.tar
target=tmp/apps/com.freestylelibre.app.de
if [ -d ${target} ] ; then
echo the unpacked app data can be found in ${target}
else
echo something went wrong when extracting the app data
exit 97
fi
exit 0