Logo

dev-resources.site

for different kinds of informations.

A zoom installer script for linux

Published at
8/24/2023
Categories
zoom
bash
dependency
linux
Author
abbazs
Categories
4 categories in total
zoom
open
bash
open
dependency
open
linux
open
Author
6 person written this
abbazs
open
A zoom installer script for linux

Often when you install zoom in linux you would have encountered broken install issue. Here is a function to save you from installing and keeping it updated:

#!/bin/bash

set -euo pipefail

print_style() {
    local style="${1:-0}"
    local color="${2:-32}"
    local message="${3:-$color}"
    echo -e "\e[${style};${color}m${message}\e[0m"
}

get_version_from_json() {
    local url="https://zoom.us/rest/download?os=linux"
    curl -s "$url" | jq -r '.result.downloadVO.zoom.version'
}

get_installed_version() {
    dpkg-query -W -f='${Version}' zoom 2>/dev/null || echo "Not installed"
}

download_zoom() {
    local version="$1"
    local filename="zoom_amd64.deb"
    print_style 1 31 "Downloading Zoom version $version"
    curl -LO "https://zoom.us/client/latest/$filename"
    echo "$filename"
}

install_dependencies() {
    local filename="$1"
    local package_names

    package_names=$(dpkg-deb -f "$filename" Depends | sed -e 's/,//g' -e 's/([^)]*)//g')

    if [[ "$package_names" == *"|"* ]]; then
        IFS='|' read -ra dep_choices <<< "$package_names"
        for choice in "${dep_choices[@]}"; do
            sudo apt-get install -y $choice && break
        done
    else
        sudo apt-get install -y $package_names
    fi
}

install_zoom() {
    local filename="$1"
    sudo dpkg -i "$filename"
    sudo apt-get install -f -y
}

update_zoom() {
    local latest_version
    local installed_version
    local filename

    latest_version=$(get_version_from_json)
    installed_version=$(get_installed_version)

    print_style 1 34 "Latest version   : $latest_version"
    print_style 1 34 "Installed version: $installed_version"

    if [ "$installed_version" = "$latest_version" ]; then
        print_style 1 32 "The current version $installed_version is already installed."
        return
    fi

    filename=$(download_zoom "$latest_version")
    install_dependencies "$filename"
    install_zoom "$filename"

    rm -f "$filename"
    print_style 1 32 "Zoom has been successfully updated to version $latest_version"
}

main() {
    if ! command -v jq &> /dev/null; then
        print_style 1 31 "jq is not installed. Please install it first."
        exit 1
    fi

    update_zoom
}

main "$@"
Enter fullscreen mode Exit fullscreen mode
dependency Article's
30 articles in total
Favicon
Ore: Advanced Dependency Injection Package for Go
Favicon
vcpkg - how to modify dependencies
Favicon
CocoaPods is in Maintenance Mode
Favicon
Safely restructure your codebase with Dependency Graphs
Favicon
Understanding Dependencies in Programming
Favicon
A zoom installer script for linux
Favicon
Loose Coupling and Dependency Injection (DI) principle
Favicon
Dependency Injection in swift
Favicon
Dependency relation in AWS CDK
Favicon
CORS how to enable them in .NET?
Favicon
Angular Dependency Injection
Favicon
Dependency management made easy with Dependabot and GitHub Actions
Favicon
Jetpack compose โ€” Dependency injection with Dagger/HILT
Favicon
Dependencies in node project
Favicon
Fixing vulnerabilities found in a dependency tree
Favicon
How to create your own dependency injection framework in Java
Favicon
Reduzindo a quantidade de Branchs na criaรงรฃo de Objetos com uma estrutura plugรกvel
Favicon
NodeJs - Dependency injection, make it easy
Favicon
A Step by Step Guide to ASP.NET Core Dependency Injection
Favicon
The Basics of Dependency Maintenance in NPM/yarn
Favicon
The troubles of modern software dependency management and what to do about them
Favicon
Loose Coupling Basics
Favicon
Correctly defining CDK dependencies in L3 constructs
Favicon
What dependency hell looks like, and how to avoid it
Favicon
How to create your own dependency injection framework in Java
Favicon
Dependency Inversion Principle in Swift
Favicon
Angular: Create a custom dependency injection
Favicon
Dagger with a Hilt
Favicon
How to find what is the dependency of a function, class, or variable in ES6 via AST
Favicon
Data Dependency Graph

Featured ones: