#!/usr/bin/env bash

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

OS="`getos`"

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

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


if [ "${OS}" = "Ubuntu" ]; then
	if [ -f /etc/apt/apt.conf.d/75lowerspeed ]; then
		rm -f /etc/apt/apt.conf.d/75lowerspeed
		echo /etc/apt/apt.conf.d/75lowerspeed removed
	else
		echo "Nothing to do"
	fi
elif [ "${OS}" = "CentOS" ]; then
	if grep -q "#throttle" /etc/yum.conf; then
		echo "Nothing to do"
	elif grep -q "throttle" /etc/yum.conf; then
		sed -i "s/throttle/#throttle/" /etc/yum.conf
	else
		echo "Nothing to do"
	fi
	cat /etc/yum.conf
else
	error "Unknown OS: ${OS}"
	exit 1
fi
