Skip to content

Instantly share code, notes, and snippets.

@yacn
Last active October 21, 2020 23:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yacn/6698cb453ac8d70d0e956c6547b74fe6 to your computer and use it in GitHub Desktop.
Save yacn/6698cb453ac8d70d0e956c6547b74fe6 to your computer and use it in GitHub Desktop.
Install/Update script for Zoom on Solus (or any linux that can use their "Other Linux" gcc 4.7+ package)
#!/usr/bin/env bash
set -e
function log() { echo "$(date +"%Y-%m-%d %H:%M:%S")" "$@"; }
pkg_url="https://zoom.us/client/latest/zoom_x86_64.tar.xz"
arch_pkg_url="https://zoom.us/client/latest/zoom_x86_64.pkg.tar.xz"
zoom_pkg="zoom_x86_64.tar.xz"
etag="zoom-etag.txt"
QT_SCALE_FACTOR="${QT_SCALE_FACTOR:=2}"
zoom_dir="${ZOOM_LOCATION:=$HOME/zoom-client/}"
app_dir="$zoom_dir/app"
zoom_launcher="$app_dir/ZoomLauncher"
zoom_launcher_desktop="$app_dir/RegisterProtocol/ZoomLauncher.desktop"
user_desktop_entries="$HOME/.local/share/applications"
log "Creating $zoom_dir"
mkdir -p "$zoom_dir" || log "$zoom_dir already exists"
function cleanup() {
# try not to blow away existing successful installs on subsequent runs
# if script interrupted or errors
if [[ -f "$user_desktop_entries/ZoomLauncher.desktop" ]]; then
exit
fi
install_creates=(
"$zoom_dir"
)
cd; echo;
for thing in "${install_creates[@]}"; do
cleanup_msg="Install interruped/failed, cleaning up $thing"
[[ -f "$thing" || -d "$thing" ]] && \
rm -rf "$thing" && \
log "$cleanup_msg"
done
}
trap cleanup INT ERR
cd "$zoom_dir"
log "Fetching latest Zoom release archive"
curl -# -L -o "$zoom_pkg" --etag-save "$etag" --etag-compare "$etag" "$pkg_url"
# was the zoom archive updated by last curl command? check if archive mtime
# is newer than one minute
if [ ! "$(find "$zoom_pkg" -mmin -1)" ]; then
log "Zoom archive matches latest available, nothing to do"
exit
fi
# extract
mkdir -p "$app_dir" || log "$app_dir already exists"
tar --strip-components 1 --directory "$app_dir" -xf "$zoom_pkg"
if [ -f "$zoom_launcher_desktop" ]; then
log "App has been launched before so we don't need to add the desktop file"
log "Zoom updated"
exit
fi
log "Launching Zoom for the first time to generate desktop file, it should quit shortly afterwards"
nohup "$zoom_launcher" > first_run.log 2>&1 &
sleep 3
killall zoom
# since Zoom doesn't seem to include Zoom.png with the "Other Linux" downloads, do something very
# stupid to get their official logo: download the Arch package and extract from that.
log "Fetching Arch package for Zoom.png"
curl -# -L "$arch_pkg_url" | \
tar --directory "$app_dir" --strip-components 3 -J -xf - usr/share/pixmaps/Zoom.png
echo "Icon=$app_dir/Zoom.png" >> "$zoom_launcher_desktop"
# Cleaning up some errors in the desktop file
sed -i 's|^Type=Network;Application$|Type=Application|' "$zoom_launcher_desktop"
sed -i 's|^Categories=Network;Application;$|Categories=Network|' "$zoom_launcher_desktop"
if zenity --question --title="HiDPI config" --text="Are you using a HiDPI screen?" --default-cancel --timeout=10; then
sed -i "s|^Exec=.*$|Exec=/usr/bin/env QT_SCALE_FACTOR=${QT_SCALE_FACTOR} $zoom_launcher %U|" "$zoom_launcher_desktop"
else
log "Either timed out and defaulted to no HiDPI or you're not running a HiDPI screen"
log "If you want to enable it later, run:"
echo
echo -e "\t"sed -i \""s|^Exec=.*$|Exec=/usr/bin/env QT_SCALE_FACTOR=2 $zoom_launcher %U|"\" $user_desktop_entries/ZoomLauncher.desktop
echo -e "\t"update-desktop-database $user_desktop_entries
echo
fi
desktop-file-validate "$zoom_launcher_desktop"; echo
desktop-file-install --dir="$user_desktop_entries" "$zoom_launcher_desktop"
update-desktop-database "$user_desktop_entries"
log "Zoom installed! For URLs to auto-launch meetings, you will need to logout and login again"
#!/usr/bin/env bash
set -e
function usage() { echo "Usage: $0 [-i]"; exit 1; }
declare interactive
if [[ ($# -le 1) && ($1 == "-i" || $1 == "") ]]; then
interactive=$1
else
usage
fi
function log() { echo "$(date +"%Y-%m-%d %H:%M:%S")" "$@"; }
zoom_dir="${ZOOM_LOCATION:=$HOME/zoom-client}"
local_desktop_files="$HOME/.local/share/applications"
zoom_launcher_desktop="$local_desktop_files/ZoomLauncher.desktop"
[ -d "$zoom_dir" ] && \
(rm -rf "$interactive" "$zoom_dir" && \
log "Removed $zoom_dir") || \
log "No $zoom_dir to remove" >&2
[ -f "$zoom_launcher_desktop" ] && \
(rm -rf "$interactive" "$zoom_launcher_desktop" && \
log "Removed $zoom_launcher_desktop" && \
log "Updating desktop database" && \
update-desktop-database "$local_desktop_files") || \
log "No $zoom_launcher_desktop to remove" >&2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment