#!/bin/bash
#
# Macroscop RedOS Repository

readonly REDOS_FILE_VERSION=$(cat /etc/os-release)

sudo rm -f /etc/yum/sources.list.d/macroscop* >/dev/null

if echo "$REDOS_FILE_VERSION" | grep -qE 'VERSION_ID="7.*"'; then
  sudo echo "[macroscop-packages]
name=Macroscop Packages
baseurl=https://packages.macroscop.com/rpm/redos/7.3
enabled=1
gpgcheck=1
gpgkey=https://packages.macroscop.com/rpm/macroscop.gpg.key" | sudo tee /etc/yum.repos.d/macroscop.repo >/dev/null
fi

if echo "$REDOS_FILE_VERSION" | grep -qE 'VERSION_ID="8.*"'; then
  sudo echo "[macroscop-packages]
name=Macroscop Packages
baseurl=https://packages.macroscop.com/rpm/redos/8
enabled=1
gpgcheck=1
gpgkey=https://packages.macroscop.com/rpm/macroscop.gpg.key" | sudo tee /etc/yum.repos.d/macroscop.repo >/dev/null
fi

sudo yum clean all

echo "Success!"
