-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInstall_Zoom.sh
More file actions
96 lines (82 loc) · 1.99 KB
/
Install_Zoom.sh
File metadata and controls
96 lines (82 loc) · 1.99 KB
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
#!/bin/zsh
# Automatically download and install the latest zoom.us
# Variables
appName="zoom.us.app"
appPath="/Applications/${appName}"
appProcessName="zoom.us"
downloadUrl="https://zoom.us/client/latest"
pkgName="ZoomInstallerIT.pkg"
cleanup () {
if [[ -f "${tmpDir}/${pkgName}" ]]; then
if rm -f "${tmpDir}/${pkgName}"; then
echo "Removed file ${tmpDir}/${pkgName}"
fi
fi
if [[ -d "${tmpDir}" ]]; then
if rm -R "${tmpDir}"; then
echo "Removed directory ${tmpDir}"
fi
fi
}
createTmpDir () {
if [ -z ${tmpDir+x} ]; then
tmpDir=$(mktemp -d)
echo "Temp dir set to ${tmpDir}"
fi
}
processCheck () {
if pgrep -x "${appProcessName}" > /dev/null; then
echo "${appProcessName} is currently running"
echo "Aborting install"
cleanup
exit 0
else
echo "${appProcessName} not currently running"
fi
}
tryDownload () {
if curl -LSs "${downloadUrl}/${pkgName}" -o "${tmpDir}/${pkgName}"; then
echo "Download successful"
tryDownloadState=1
else
echo "Download unsuccessful"
tryDownloadCounter=$((tryDownloadCounter+1))
fi
}
versionCheck () {
if [[ -d "${appPath}" ]]; then
echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)"
versionCheckStatus=1
else
echo "${appName} not installed"
versionCheckStatus=0
fi
}
# Start
# List version
versionCheck
# Download PKG file into ${tmpDir} (60 second timeout)
tryDownloadState=0
tryDownloadCounter=0
while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do
processCheck
createTmpDir
tryDownload
sleep 1
done
# Check for successful download
if [[ ! -f "${tmpDir}/${pkgName}" ]]; then
echo "Download unsuccessful"
cleanup
exit 1
fi
# Install package
echo "Starting install"
installer -pkg "${tmpDir}/${pkgName}" -target /
# Remove tmp dir and downloaded pkg file
cleanup
# List version and exit with error code if not found
versionCheck
if [[ ${versionCheckStatus} -eq 0 ]]; then
exit 1
fi