#!/bin/bash -e

. ../../xi-sys.cfg

if [ "$distro" == "Ubuntu" ]; then
    # Installing the apt package also adds the chromium-browser command, installs as snap
    apt-get install -y xdg-utils
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
    sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
    rm google-chrome-stable_current_amd64.deb
    # Enabling linger allows the cron user to effectively run as nagios with snaps
    # https://forum.snapcraft.io/t/system-slice-cron-service-is-not-a-snap-cgroup/30196/5
    loginctl enable-linger $nagiosuser
elif [ "$distro" == "Debian" ]; then
    apt-get install -y xdg-utils
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
    sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
    rm google-chrome-stable_current_amd64.deb
else
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
    sudo dnf install -y ./google-chrome-stable_current_x86_64.rpm
fi
echo "INSTALL: Chromium installed OK."