aboutsummaryrefslogtreecommitdiffstats
path: root/configure-mirror
diff options
context:
space:
mode:
Diffstat (limited to 'configure-mirror')
-rwxr-xr-xconfigure-mirror37
1 files changed, 37 insertions, 0 deletions
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