blob: a66ec01feb16beb60e7ac56b470f3a36cad11b65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/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=${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
|