#!/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 if test ! -f "${file}.dist"; then cp "${file}" "${file}.dist" fi grep -q -e "baseurl=$furl" "${file}.dist" || continue echo "# mirror: $furl -> $turl ($file)" sed -e 's/^mirrorlist/#mirrorlist/' \ -e 's/^metalink/#metalink/' \ -e 's/^#baseurl/baseurl/' \ -e 's/^# baseurl/baseurl/' \ -e "s|baseurl=${furl}|baseurl=${turl}|" \ < "${file}.dist" > "$file" done } # # use fixed (configurable) mirror. # be cache proxy friendly. # set_baseurl http://mirror.centos.org/centos/ "${CENTOS_MIRROR}" CENTOS_MIRROR set_baseurl http://download.fedoraproject.org/pub/epel/ "${EPEL_MIRROR}" EPEL_MIRROR set_baseurl http://download.fedoraproject.org/pub/fedora/linux/ "${FEDORA_MIRROR}" FEDORA_MIRROR set_baseurl http://download.example/pub/fedora/linux/ "${FEDORA_MIRROR}" FEDORA_MIRROR # # no parallel downloads please. # if test -f /etc/dnf/dnf.conf; then grep -q max_parallel_downloads /etc/dnf/dnf.conf ||\ echo max_parallel_downloads=1 >> /etc/dnf/dnf.conf fi if test -f /etc/yum.conf; then grep -q max_connections /etc/yum.conf ||\ echo max_connections=1 >> /etc/yum.conf fi exit 0