-
Notifications
You must be signed in to change notification settings - Fork 2
/
zoom-upd
executable file
·112 lines (95 loc) · 3.62 KB
/
zoom-upd
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
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/zoom-upd
#
ubuntu=0
redhat=0
unk=0
WGET=$(which wget 2>/dev/null)
CURL=$(which curl 2>/dev/null)
if [ "${WGET}" -a -x "${WGET}" ]
then
FETCH="wget --quiet"
UA="-U"
OUT="-O"
elif [ "${CURL}" -a -x "${CURL}" ]
then
FETCH="curl --silent"
UA="-A"
OUT="-o"
else
echo "wget or curl is required"
exit 1
fi
# handle version strings of '5.4.3 (54779.1115)'
# or '5.4 (54779.1115)'
# or '5.4.54779.1115'
# or '5.8.0 (16)'
### REST URL Update: curl 'https://zoom.us/rest/download?os=linux'
### {"status":true,"errorCode":0,"errorMessage":null,"result":{"isPageJoinOnly":false,"isCN":false,"fromGov":false,"downloadVO":{"zoom":{"version":"5.12.2.4816","displayVersion":"5.12.2 (4816)","packageName":null},"zoomX86":{"version":"5.4.53391.1108","displayVersion":"5.4.2 (53391.1108)","packageName":null},"updateDate":"1667347200000","newestGPGKeyVer":null,"historyGPGKeyVer":null},"os":"linux"}}
rzv=$(${FETCH} ${UA} "Mozilla/5.0 (X11; Linux x86_64)" ${OUT} - 'https://zoom.us/rest/download?os=linux' | grep -Eo '"zoom":{"version":"[0-9.]+"' | cut -f6 -d\" )
# sed 's/.*Version //; s|</span>.*||; s/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\) (\([0-9]\+\.[0-9]\+\))/\1.\2.\4/; s/\([0-9]\+\)\.\([0-9]\+\) (\([0-9]\+\.[0-9]\+\))/\1.\2.\3/; s/ (\(.*\))/.\1/g;' )
# expand the detection for different OS's as needed
if [ -n "$(which apt 2>/dev/null)" ]
then
ubuntu=1
EXT=deb
elif [ -n "$(which rpm 2>/dev/null)" ]
then
redhat=1
EXT=rpm
elif [ -n "$(which pacman 2>/dev/null)" ]
then
arch=1
EXT=pkg.tar.xz
else
unk=1
EXT=tar.xz
fi
if [ ${DEBUG:-0} -gt 0 ]
then
echo "won't download or install"
echo """${FETCH} ${UA} \"Mozilla/5.0 (X11; Linux x86_64)\" ${OUT} /tmp/zoom-${rzv:-0}-amd64.$EXT https://zoom.us/client/latest/zoom_amd64.$EXT"""
else
# expand the individual OS sections as needed
if [ 1 -eq ${ubuntu:-0} ]
then
lzv=$(dpkg -l zoom 2>&1 | grep ^ii | awk '{print $3}')
dpkg --compare-versions ${lzv:-0} lt ${rzv:-0}
if [ $? -eq 0 ]
then
echo "Upgrade needed"
${FETCH} ${UA} "Mozilla/5.0 (X11; Linux x86_64)" ${OUT} /tmp/zoom-${rzv:-0}-amd64.deb https://zoom.us/client/latest/zoom_amd64.deb
sudo dpkg -i /tmp/zoom-${rzv:-0}-amd64.deb
rm -i /tmp/zoom-${rzv:-0}-amd64.deb
else
echo "no newer version available"
fi
elif [ 1 -eq ${redhat:-0} ]
then
lzv=$(rpm -q zoom --info 2>&1 | grep Version | cut -f2 -d:)
# need to compare current version vs remote version
${FETCH} ${UA} "Mozilla/5.0 (X11; Linux x86_64)" ${OUT} /tmp/zoom-${rzv:-0}-x86_64.rpm https://zoom.us/client/latest/zoom_x86_64.rpm
# because we might need dependencies
sudo yum install /tmp/zoom-${rzv:-0}-x86_64.rpm
rm -i /tmp/zoom-${rzv:-0}-x86_64.rpm
elif [ 1 -eq ${arch:-0} ]
then
# Need to detect the current version
# need to compare current version vs remote version
${FETCH} ${UA} "Mozilla/5.0 (X11; Linux x86_64)" ${OUT} /tmp/zoom-${rzv:-0}-x86_64.pkg.tar.xz https://zoom.us/client/latest/zoom_x86_64.pkg.tar.xz
# This grabs dependencies
pacman -U /tmp/zoom-${rzv:-0}-x86_64.pkg.tar.xz
rm -i /tmp/zoom-${rzv:-0}-x86_64.pkg.tar.xz
elif [ 1 -eq ${unk:-0} ]
then
# Need to detect the current version
# need to compare current version vs remote version
${FETCH} ${UA} "Mozilla/5.0 (X11; Linux x86_64)" ${OUT} /tmp/zoom-${rzv:-0}-x86_64.tar.xz https://zoom.us/client/latest/zoom_x86_64.tar.xz
echo "You'll need to manually install from the package"
else
echo "Can't determine version for automatic upgrade"
fi
fi