change mirror country automatically based on ipinfo

This commit is contained in:
Jeffrey Paul 2021-06-10 16:33:45 -07:00
parent b5ac536cf5
commit d6fa8fd8ec

22
prov.sh
View File

@ -4,10 +4,32 @@ export DEBIAN_FRONTEND=noninteractive
function main() {
RELEASE="$(lsb_release -cs)"
apt update
prov-$RELEASE
}
function detect-mirror-country() {
apt install -y jq curl
curl ipinfo.io | jq -r .country
}
function set-mirror-country() {
MURM="main universe restricted multiverse"
COUNTRY="$(detect-mirror-country)"
URL="http://$COUNTRY.archive.ubuntu.com/ubuntu"
cat > /etc/apt/sources.list.new <<EOF
deb $URL $(lsb_release -cs) $MURM
deb $URL $(lsb_release -cs)-updates $MURM
deb $URL $(lsb_release -cs)-backports $MURM
deb $URL $(lsb_release -cs)-security $MURM
EOF
}
function prov-focal() {
set-mirror-country
PKGS="
bridge-utils
byobu