summaryrefslogtreecommitdiff
path: root/configs/releng/airootfs/usr/local/bin/choose-mirror
blob: 2f881e48e20466f4fa57890549b2ec1333771261 (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
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later

get_cmdline() {
    local param
    for param in $(</proc/cmdline); do
        case "${param}" in
            "${1}="*)
                echo "${param##*=}"
                return 0
                ;;
        esac
    done
}

mirror="$(get_cmdline mirror)"
[[ "$mirror" == 'auto' ]] && mirror="$(get_cmdline parabolaiso_http_srv)"
[[ -n "$mirror" ]] || exit 0

mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig
cat >/etc/pacman.d/mirrorlist <<EOF
#
# Parabola GNU/Linux-libre repository mirrorlist
# Generated by parabolaiso
#

Server = ${mirror%%/}/\$repo/os/\$arch
EOF