#!/bin/bash

# add vivaldi repo and key, these will immediately be overwritten and managed by vivaldi when the deb is installed
sudo mkdir -p /etc/apt/trusted.gpg.d
wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/vivaldi-4218647E.gpg >/dev/null || exit 1
echo "deb [arch=$(dpkg --print-architecture)] https://repo.vivaldi.com/archive/deb/ stable main" | sudo tee /etc/apt/sources.list.d/vivaldi.list >/dev/null

(install_packages vivaldi-stable)
if [ $? != 0 ];then
  #exit cleanly if package failed to install
  sudo rm -f /etc/apt/trusted.gpg.d/vivaldi-4218647E.gpg /etc/apt/sources.list.d/vivaldi.list
  exit 1
fi
