#!/usr/bin/env bash

. /usr/share/dosis2/bin/shell-support-functions

OS="`getos`"

function error() {
    echo -e "\033[31m$1\033[0m"
}

function warning() {
    echo -e "\033[033m$1\033[0m"
}

if [ ${UID} != 0 ]; then
    error "This script must be ran as root"
    exit 1
fi

if [ "${OS}" = "CentOS" ]; then
    if [ -f "/etc/yum.repos.d/atrpms.repo" ]; then
        echo "Disabling atrpms"
        /opt/dosis2/bin/conf-edit "/etc/yum.repos.d/atrpms.repo" --output "/etc/yum.repos.d/atrpms.repo" \
            --set atrpms.enabled=0 \
            --set atrpms-debuginfo.enabled=0 \
            --set atrpms-source.enabled=0
    fi

    if [ -f "/etc/yum.repos.d/nux-dextop.repo" ]; then
        echo "Disabling Nux Dextop"
        /opt/dosis2/bin/conf-edit "/etc/yum.repos.d/nux-dextop.repo" --output "/etc/yum.repos.d/nux-dextop.repo" \
            --set nux-dextop.enabled=0 \
            --set nux-dextop-testing.enabled=0
    fi
else
    warning "disable-dead-repos is currently only supported on CentOS at the moment; doing nothing"
fi