#!/usr/bin/env bash

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

# if another value isn't given default to 32kBps. 
LIMIT="${1:-32}"

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

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

echo "
Acquire
{
   Queue-mode \"access\";
   http
   {
      Dl-Limit \"${LIMIT}\";
   };
};
" > /etc/apt/apt.conf.d/75lowerspeed
cat /etc/apt/apt.conf.d/75lowerspeed

