#!/bin/bash

if [ ${DEBUG_TRACE:-0} -gt 0 ]; then
    set -x
fi
set -eu
set -o pipefail
set -x

if [ -e /etc/yum.repos.d/tmp.repo ]; then
    rm -rf /etc/yum.repos.d/tmp.repo
fi

ls /etc/yum.repos.d/

if [ "X$ISO" == "X" ]; then
    rm -rf /etc/yum.repos.d/tmp*.repo || true
fi

if [ -d /var/cache/yum ]; then
    rm -rf /var/cache/yum
fi

if [ -d /var/lib/yum/history ]; then
    rm -rf /var/lib/yum/history
fi

_repos=`ls /etc/yum.repos.d/ | wc -l`

if [ "$_repos" != "0" ]; then
    sed -i "s/enabled=0/enabled=1/g" /etc/yum.repos.d/*
fi
