From e99fccf4c741025bf6353b96635ad9690e250bf7 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 19 Aug 2020 10:25:48 +0200 Subject: add configure-mirror --- Dockerfile | 2 +- configure-mirror | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 configure-mirror diff --git a/Dockerfile b/Dockerfile index 6ce2ef1..95e679d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,5 +9,5 @@ LABEL maintainer="Gerd Hoffmann " \ USER root -COPY configure-podman /usr/local/bin +COPY configure-* /usr/local/bin RUN /usr/local/bin/configure-podman diff --git a/configure-mirror b/configure-mirror new file mode 100755 index 0000000..1b7ba55 --- /dev/null +++ b/configure-mirror @@ -0,0 +1,37 @@ +#!/bin/sh + +function set_baseurl() { + local furl="$1" + local turl="$2" + local name="$3" + local file + + if test "$turl" = ""; then + echo "# no mirror: $furl (env \$$name)" + return + fi + + for file in /etc/yum.repos.d/*.repo; do + grep -q -e "baseurl=$furl" || continue + echo "# mirror: $furl -> $turl ($file)" + sed -i.orig \ + -e 's/^mirrorlist/#mirrorlist/' \ + -e 's/^#baseurl/baseurl/' \ + -e "s|baseurl=${furl}|baseurl=${turl}|" \ + "$file" + diff "${file}.orig" "$file" + done +} + +# +# use fixed (configurable) mirror. +# be cache proxy friendly. +# +set_baseurl http://mirror.centos.org/ "${CENTOS_MIRROR}" CENTOS_MIRROR +set_baseurl http://download.fedoraproject.org/ "${FEDORA_MIRROR}" FEDORA_MIRROR + +# +# no parallel downloads please. +# +grep -q max_parallel_downloads /etc/dnf/dnf.conf ||\ +echo max_parallel_downloads=1 >> /etc/dnf/dnf.conf -- cgit