summarylogtreecommitdiffstats
path: root/latest-arch-mirrorlist
blob: 9c91acd047c46b9ac08a1d16a7ea67f798280b22 (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
#!/bin/bash

# Fetch the latest Arch mirrorlist.
# Use the file as target if given, otherwise
#  - save it to /tmp
#  - then display the full file path to stdout

Main()
{
    local full_list="$1"
    local file_given=no
    local ARCH_SITE=https://www.archlinux.org

    if [ -z "$full_list" ]; then
        full_list=/tmp/arch-mirrorlist-latest.$(date +%Y-%m-%d)
    else
        file_given=yes
    fi
    curl -Lsm 10 -o "$full_list" $ARCH_SITE/mirrorlist/all || {
        return 1
    }
    if [ "$file_given" = "no" ] ; then
        echo "$full_list"
    fi
}

Main "$@"