#!/bin/bash
set -e

export LANG=C
export LC_ALL=C
LOG_FILE=/var/log/tuxedo-install-default-snaps.log

DEBIAN_FRONTEND=noninteractive dpkg --configure -a 2>&1 | tee -a ${LOG_FILE}
DEBIAN_FRONTEND=noninteractive apt-get --reinstall install -y snapd firefox thunderbird 2>&1 | tee -a ${LOG_FILE}

if snap list | grep -q "core"; then
    snap refresh core --classic 2>&1 | tee -a ${LOG_FILE} || true
else
    snap install core --classic 2>&1 | tee -a ${LOG_FILE} || true
fi

if snap list | grep -q "snap-store"; then
    snap refresh snap-store --classic 2>&1 | tee -a ${LOG_FILE} || true
else
    snap install snap-store --classic 2>&1 | tee -a ${LOG_FILE} || true
fi

if snap list | grep -q "thunderbird"; then
    snap refresh thunderbird --classic 2>&1 | tee -a ${LOG_FILE} || true
else
    snap install thunderbird --classic 2>&1 | tee -a ${LOG_FILE} || true
fi

unset LC_ALL
unset LANG

exit 0;
