-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsideload-check-updates
executable file
·83 lines (65 loc) · 2.54 KB
/
sideload-check-updates
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
#!/bin/bash
source sideloader-config
## rclone mount BRANCHBIT:q2_working_confirmed /tmp/mnt &
clearLog
deviceCheck
if [ "$(ls -A $MNTLOC/ 2>/dev/null)" ]; then
ok "Drive mounted at: $MNTLOC ($(ls $MNTLOC | wc -l) folders available)\n\n"
else
error "Cannot use this function when drive is not mounted"
dialogLog
exit 0
fi
#[ -z $CI ] && zenity --question --width=800 --text="Update and use local versionlist? ($(date -r "/tmp/badgelist.txt" +"%Y-%m-%d %H:%M:%S")) ($(cat "/tmp/badgelist.txt" | wc -l) items)\n\n
# If not we will use the remote one from ($(date -r "$MNTLOC/badgelist.txt" +"%Y-%m-%d %H:%M:%S")) ($(cat "$MNTLOC/badgelist.txt" | wc -l) items) and copy to local."
#if [ $? != 0 ]; then
# [ -z $CI ] && cp $MNTLOC/badgelist.txt "/tmp/badgelist.txt"
#else
# [ -z $CI ] && sideload-updatebadges
# echo -n ''
#fi
cp $MNTLOC/badgelist.txt "/tmp/badgelist.txt"
INSTALLEDPACKAGES="$($ADB shell cmd package list packages -3 | cut -f 2 -d":")"
info "CHECKING INSTALLED APPS:"
info "=========================="
info "$INSTALLEDPACKAGES"
info "=========================="
info "CHECKING DRIVE FOR UPDATES:"
info "=========================="
IFS='
'
for line in $INSTALLEDPACKAGES; do
PACKAGETOCHECK="$line"
#echo "CHECKING $PACKAGETOCHECK"
OLDVERSION=$($ADB shell dumpsys package $PACKAGETOCHECK)
regex="versionCode=([0-9]*)"
[[ $OLDVERSION =~ $regex ]]
VERSIONTOCHECK=${BASH_REMATCH[1]}
#echo "${BASH_REMATCH[0]}"
#echo old version: $VERSIONTOCHECK
#echo "$line"
while read badgeline; do
#echo "checking $line against $PACKAGETOCHECK"
if [[ "$badgeline" == *"$PACKAGETOCHECK"* ]]; then
#echo "MATCH"
APKNAME=${badgeline%%|*}
APKLOC=${badgeline##*|}
APKVERSION=${badgeline#*|}
APKVERSION=${APKVERSION%|*}
#echo "INSTALLED: $APKNAME"
#echo "LOCATION ON DRIVE: $APKLOC"
#echo "VERSION ON DRIVE: $APKVERSION"
if [[ "$APKVERSION" -gt "$VERSIONTOCHECK" ]]; then
ok "<b>[+] NEWER VERSION OF $(echo "$APKNAME") FOUND, CURRENT: ($(echo "$VERSIONTOCHECK")), DRIVE: ($(echo "$APKVERSION"))</b>"
elif [[ "$APKVERSION" -lt "$VERSIONTOCHECK" ]]; then
ok "[-] OLDER VERSION OF $(echo "$APKNAME") FOUND, CURRENT: ($(echo "$VERSIONTOCHECK")), DRIVE: ($(echo "$APKVERSION"))"
elif [[ "$APKVERSION" -eq "$VERSIONTOCHECK" ]]; then
ok "[=] SAME VERSION OF $(echo "$APKNAME") FOUND, CURRENT: ($(echo "$VERSIONTOCHECK")), DRIVE: ($(echo "$APKVERSION"))"
fi
fi
#echo "$line"
done <"/tmp/badgelist.txt"
done
info "==========================\n"
dialogLog
exit 0