#/usr/bin/env bash
source /etc/os-release

## This is the latest version of Snakeoil
SNAKEOIL_VERSION="1.3.0"

## Your architecture
ARCH=$(uname -m)

## Download URL
DOWNLOAD_URL="https://artifacts.snakeoil-os.net/artifacts/snakeoil-installer-${VERSION_CODENAME}-${ARCH}-${SNAKEOIL_VERSION}.sh"

## Download location
DOWNLOAD_LOCATION="/tmp/snakeoil-installer.sh"

echo "Downloading: ${DOWNLOAD_URL}"

wget -qLO ${DOWNLOAD_LOCATION} ${DOWNLOAD_URL}

FILESIZE=$(stat -c %s ${DOWNLOAD_LOCATION})

if [ ${FILESIZE} -eq 0 ]; then
  echo "Install failed, OS not supported?"
  echo ""
  echo "Version: $VERSION_CODENAME"
  echo "   Arch: $ARCH"
  echo ""
  echo "Join the Snakeoil forums for support: https://www.snakeoil-os.net/forums)"
else
  bash ${DOWNLOAD_LOCATION}
fi

