Skip to content

Instantly share code, notes, and snippets.

@nathanchere
Created March 22, 2017 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nathanchere/c5d1d1d40f7b3288521513dd6409df9d to your computer and use it in GitHub Desktop.
Save nathanchere/c5d1d1d40f7b3288521513dd6409df9d to your computer and use it in GitHub Desktop.
Install Vivaldi browser (latest) on RPM-based Linux distros
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root. Try sudo ./install_vivaldi.sh"
exit 1
fi
latestVivaldiRpmUrl() {
echo $(curl -sL "https://vivaldi.com/download" | grep "https.*vivaldi-stable-.*.x86_64.rpm" | cut -d '"' -f 4)
}
latestVivaldiVersion() {
echo $(curl -sL "https://vivaldi.com/download" | grep -E "https.*vivaldi-stable-.*.x86_64.rpm" | cut -d '"' -f 4 | cut -d '/' -f 5 | cut -d '-' -f 3 )
}
echo "Checking installed vs latest Vivaldi versions"
INSTALLEDVERSION=$(installedVersion "vivaldi-stable")
LATESTVERSION=$(latestVivaldiVersion)
if [ "$INSTALLEDVERSION" == "$LATESTVERSION" ]; then
echo "Latest version $LATESTVERSION already installed"
exit 0
fi
if [ "$INSTALLEDVERSION" == "" ]; then
echo "No previous Vivaldi installation detected; installing $LATESTVERSION"
else
echo "Outdated version $INSTALLEDVERSION installed; updating to $LATESTVERSION"
fi
DOWNLOADURL=$(latestVivaldiRpmUrl)
INSTALLER="$(mktemp -u).vivaldi.rpm"
echo "Downloading from $DOWNLOADURL to $INSTALLER"
curl -L "$(latestVivaldiRpmUrl)" -o "$INSTALLER"
dnf install -y "$INSTALLER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment