Skip to content

Instantly share code, notes, and snippets.

@pboesch
Last active November 17, 2022 15:22
Show Gist options
  • Save pboesch/4cc656e259ea8351b45b495df1fc3727 to your computer and use it in GitHub Desktop.
Save pboesch/4cc656e259ea8351b45b495df1fc3727 to your computer and use it in GitHub Desktop.
Update Zoom, Rocket.Chat and Mattermost deb
#!/bin/sh
if [ $(id -u) -ne 0 ] ; then echo "Please run as root" ; exit 1 ; fi
f_update() {
current=$(dpkg -l | grep $1 | awk '{ print $3 }' | cut -d'-' -f1)
if [ "$1" = "zoom" ];
then
url="https://zoom.us/client/latest/zoom_amd64.deb"
dest="/tmp/zoom_amd64.deb"
latest=$(curl 2>&1 -I ${url} | grep location | grep -oP '(?<=prod\/).*(?=\/zoom_amd64.deb)')
elif [ "$1" = "rocket" ];
then
latest=$(curl 2>&1 https://github.com/RocketChat/Rocket.Chat.Electron/releases/latest | grep -oP '(?<=\/tag\/).*(?=\">redirected)')
url="https://github.com/RocketChat/Rocket.Chat.Electron/releases/download/${latest}/rocketchat_${latest}_amd64.deb"
dest="/tmp/rocket_amd64.deb"
elif [ "$1" = "mattermost" ];
then
latest=$(curl 2>&1 -I https://github.com/mattermost/desktop/releases/latest | grep -oP '(?<=\/tag\/v).....')
url="https://github.com/mattermost/desktop/releases/download/v${latest}/mattermost-desktop_${latest}-1_amd64.deb"
dest="/tmp/mattermost_amd64.deb"
else
exit 1
fi
if [ "${current}" = "${latest}" ];
then
echo "$1 is already up to date."
else
wget -q --show-progress ${url} -O ${dest}
pkill $1
dpkg -i ${dest}
if [ "$1" = "rocket"]; then
chown -R $SUDO_USER: /opt/Rocket.Chat
fi
if [ "$1" = "mattermost" ]; then
chown -R $SUDO_USER: /opt/Mattermost
fi
rm -f ${dest}
fi
}
main() {
f_update zoom
f_update rocket
f_update mattermost
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment