#!/bin/bash
##
## Install basic packages for a desktop
## (Usually Mint, but debian based)
##

echo "Updating software catalog"
apt update

echo "Upgrading..."
apt -y upgrade

echo "Installing base software (stage 1)"
apt -y install curl wget vim net-tools

echo "Installing APT add-ons"
apt -y install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates 

echo "Adding Nextcloud repo"
add-apt-repository -y ppa:nextcloud-devs/client

echo "Adding VeraCrypt repo"
add-apt-repository -y ppa:unit193/encryption

echo "Adding QOwnNotes repo"
add-apt-repository -y ppa:pbek/qownnotes

echo "Adding Element repo"
wget -O /usr/share/keyrings/element-io-archive-keyring.gpg https://packages.element.io/debian/element-io-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/element-io-archive-keyring.gpg] https://packages.element.io/debian/ default main" | tee /etc/apt/sources.list.d/element-io.list

echo "Adding Vivaldi repo"

curl https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor -o /etc/apt/trusted.gpg.d/vivaldi.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/vivaldi.gpg] https://repo.vivaldi.com/archive/deb/ stable main" | tee /etc/apt/sources.list.d/vivaldi.list

echo "Updating software catalog"
apt update

echo "Installing base software (stage 2)"
apt -y install htop jq less mc pwgen strace tcpdump dialog telnet rsync restic \
       git git-lfs yubico-piv-tool yubikey-manager-qt \
       sqlite3 python3-pip python3-virtualenv python3-sqlalchemy python3-dateutil

echo "Installing add-on software"
apt -y install nextcloud-desktop veracrypt element-desktop qownnotes vivaldi-stable

echo "Installing productivity"
apt -y install evolution evolution-ews xed gimp libreoffice-writer libreoffice-calc gthumb \
               keepassx spotify-client

echo "Check if FlatPack exists"
flatpak --version >/dev/null 2>/dev/null
FLATPACK=$?

if [ $FLATPACK -eq 0 ]
then
   echo "Flatpack installed"
   flatpak install -y org.telegram.desktop
   flatpak install -y "Slack"
   flatpak install -y "Zoom"
   flatpak install -y com.dropbox.Client
else
   echo "Flatpack not installed"
fi
