Create a gist now

Instantly share code, notes, and snippets.

Vivaldi Bash Installer
Vivaldi BASH Installer
CAUTION: This code is provided AS-IS with NO warranties or guarantees. The code worked great in my environment.
You are free to review the code to see what it is doing and make any changes. Still you are responsible for YOUR system(s).
It is my hope it does aid you in saving time and effort. Good luck.
There are two files:
1) vivaldi-debian-bash.sh => Is for Debian based Linuxes running on 64-bit hardware
2) vivaldi-general-bash.sh => Is for Debian and RPM based Linuxes running on 32 or 64-bit hardware
Both installers will download the latest version to your ~/Downloads/ from the Vivaldi repo (using curl),
install it (using gdebi, yum, or dnf), and then remove the file.
I have used "vivaldi-debian-bash.sh" in my environment. However since I prefer Debian based desktop Linuxes I have NOT
heavily tested "vivaldi-general-bash.sh". I don't run 32-bit hardware or RPM based Linux desktops. The checks were
returning the correct files. Do feel free to let me know should you encounter a problem and I'll see what I can do to
fix the code. Still NO guarantees are implied.
Also both scripts are written to run, on their own, after download, and execute permission set. However, obviously, one
could incorporate the code into a more extensive script or call it from another.
Requirements:
1) curl - Required for both scripts
Missing?
debian based> sudo apt-get install curl
rpm based> sudo yum install curl -OR- > sudo dnf install curl
2) gdebi - Needed for Debian based installs
Missing?
> sudo apt-get install gdebi
#!/bin/bash
# Vivaldi BASH Installer For Current Version on Debian/Ubuntu Linux 64 Bit
# Jeremy O'Connell @ https://www.cyberws.com/
# Version: 1.1
# Vivaldi REPO URL
VIVALDI_REPO_URL="http://repo.vivaldi.com/stable/deb/pool/main/"
# Get information for Vivaldi repo and remove line breaks
VIVALDI_DL_PG=`curl $VIVALDI_REPO_URL | tr "\n" '|||'`
# Remove HTML and extra spaces
VIVALDI_DL_PG=`echo $VIVALDI_DL_PG | sed 's|<[^>]*>||g' | sed -e's/ */ /g'`
# Make an array
IFS='|' read -a VIVALDI_DL_ARRAY <<< "$VIVALDI_DL_PG"
# Set current version
VIVALDI_CURRENT_VERSION='1'
# Process repo entries
for VIVALDI_DL_ITEM in "${VIVALDI_DL_ARRAY[@]}"
do
# If a stable version and amd64
if [[ $VIVALDI_DL_ITEM == *"vivaldi-stable_"* ]] && [[ $VIVALDI_DL_ITEM == *"_amd64.deb"* ]]
then
IFS=' ' read -a VIVALDI_DL_ITEM_DATA <<< "${VIVALDI_DL_ITEM}"
DL_FILE_NAME="${VIVALDI_DL_ITEM_DATA[0]}"
# Get file version
IFS='_' read -a VIVALDI_FILE_NAME_DATA <<< "$DL_FILE_NAME"
DL_FILE_VERSION="${VIVALDI_FILE_NAME_DATA[1]}"
# Update current version if file version is greater
if (( $(echo "$DL_FILE_VERSION $VIVALDI_CURRENT_VERSION" | awk '{print ($1 > $2)}') ))
then
VIVALDI_CURRENT_VERSION="$DL_FILE_VERSION"
fi
fi
done
# Set current version file name
VIVALDI_DL_FILE='vivaldi-stable_'$VIVALDI_CURRENT_VERSION'_amd64.deb'
# Download, install, then remove file
cd ~/Downloads/
curl -O $VIVALDI_REPO_URL$VIVALDI_DL_FILE
sudo gdebi -n $VIVALDI_DL_FILE
rm -f $VIVALDI_DL_FILE
#!/bin/bash
# Vivaldi BASH Installer For Current Version On DEB and RPM Based 32-bit and 64-bit Linuxes
# Jeremy O'Connell @ https://www.cyberws.com/
# Not as well tested - use at your own risk
# Version 1.0
# Set important variables
# Vivaldi Branch To Install
VIVALDI_BRANCH="vivaldi-stable"
# Vivaldi DEB REPO URL
VIVALDI_REPO_URL="http://repo.vivaldi.com/stable/deb/pool/main/"
# System Installer
SYSTEM_INSTALLER="gdebi -n"
# Vivaldi Package Type
VIVALDI_PACKAGE_TYPE="deb"
# Does system use yum?
if command -v yum >/dev/null 2>&1
then
SYSTEM_INSTALLER="yum install"
VIVALDI_PACKAGE_TYPE="rpm"
fi
# Does system use dnf?
if command -v dnf >/dev/null 2>&1
then
SYSTEM_INSTALLER="dnf install"
VIVALDI_PACKAGE_TYPE="rpm"
fi
# System Bit Type - 64 or 32
SYSTEM_BIT_TYPE=`uname -m`
if test "$SYSTEM_BIT_TYPE" == "x86_64"
then
# Set branch correctly and file type - different methods for rpm vs deb
if test "$VIVALDI_PACKAGE_TYPE" == "rpm"
then
VIVALDI_REPO_URL="http://repo.vivaldi.com/stable/rpm/x86_64/"
VIVALDI_BRANCH=$VIVALDI_BRANCH'-'
VIVALDI_FILE="-1.x86_64.$VIVALDI_PACKAGE_TYPE"
else
VIVALDI_BRANCH=$VIVALDI_BRANCH'_'
VIVALDI_FILE="_amd64.$VIVALDI_PACKAGE_TYPE"
fi
else
# Set branch correctly and file type - different methods for rpm vs deb
if test "$VIVALDI_PACKAGE_TYPE" == "rpm"
then
VIVALDI_REPO_URL="http://repo.vivaldi.com/stable/rpm/i386/"
VIVALDI_BRANCH=$VIVALDI_BRANCH'-'
VIVALDI_FILE="-1.i386.$VIVALDI_PACKAGE_TYPE"
else
VIVALDI_BRANCH=$VIVALDI_BRANCH'_'
VIVALDI_FILE="_i386.$VIVALDI_PACKAGE_TYPE"
fi
fi
# Get information for Vivaldi repo and remove line breaks
VIVALDI_DL_PG=`curl $VIVALDI_REPO_URL | tr "\n" '|||'`
# Remove HTML and extra spaces
VIVALDI_DL_PG=`echo $VIVALDI_DL_PG | sed 's|<[^>]*>||g' | sed -e's/ */ /g'`
# Make an array
IFS='|' read -a VIVALDI_DL_ARRAY <<< "$VIVALDI_DL_PG"
# Set current version
VIVALDI_CURRENT_VERSION='1'
# Process repo entries
for VIVALDI_DL_ITEM in "${VIVALDI_DL_ARRAY[@]}"
do
# If a stable version and amd64
if [[ $VIVALDI_DL_ITEM == *"$VIVALDI_BRANCH"* ]] && [[ $VIVALDI_DL_ITEM == *"$VIVALDI_FILE"* ]]
then
IFS=' ' read -a VIVALDI_DL_ITEM_DATA <<< "${VIVALDI_DL_ITEM}"
DL_FILE_NAME="${VIVALDI_DL_ITEM_DATA[0]}"
# Get file version - different methods for rpm vs deb
if test "$VIVALDI_PACKAGE_TYPE" == "rpm"
then
IFS='-' read -a VIVALDI_FILE_NAME_DATA <<< "$DL_FILE_NAME"
DL_FILE_VERSION="${VIVALDI_FILE_NAME_DATA[2]}"
else
IFS='_' read -a VIVALDI_FILE_NAME_DATA <<< "$DL_FILE_NAME"
DL_FILE_VERSION="${VIVALDI_FILE_NAME_DATA[1]}"
fi
# Update current version if file version is greater
if (( $(echo "$DL_FILE_VERSION $VIVALDI_CURRENT_VERSION" | awk '{print ($1 > $2)}') ))
then
VIVALDI_CURRENT_VERSION="$DL_FILE_VERSION"
fi
fi
done
# Set download file
VIVALDI_DL_FILE=$VIVALDI_BRANCH$VIVALDI_CURRENT_VERSION$VIVALDI_FILE
# Download, install, then remove file
cd ~/Downloads/
curl -O $VIVALDI_REPO_URL$VIVALDI_DL_FILE
sudo $SYSTEM_INSTALLER $VIVALDI_DL_FILE
rm -f $VIVALDI_DL_FILE
@amethystrender

this is monkey_wrench_gang898@vivaldi.net. i appreciate your help. i usually edit my own file locations over pre-made ones. i intentionally left it open-ended, as i am grateful for whatever assistance you lend, and other users may have different needs. i was unsure if i should do communication for this kind of project on github. i am new there, not yet used to format. in terms of programming, i was trying to write a script for detecting deb/rpm systems. couldn't find multiboot on !so, so i was rigging it up with $ file /bin/dnf | [variable].
fedora/korora yum redirects to dnf (DaNdiFied yum). i guess theyre crossing over to the new package manager, although there doesn't seem to be a front-end change for me.

@cleverwise
Owner

Well if you haven't already the "vivaldi-general-bash.sh" will auto detect the package type (deb, yum, or dnf), so you are good to go.

Cheers,

Jeremy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment