diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2017-05-19 13:54:27 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2017-05-19 13:54:27 +0200 |
commit | cb07fb94061a8e4c3c815244b697dffe81e0688c (patch) | |
tree | b2095fe43b05ccda637b09d1fc1cc652476b21b5 /setup-apkrepos.in | |
parent | b421b06686607c0fa13ec0ce99b33d1c9fc728e7 (diff) | |
download | alpine-conf-cb07fb94061a8e4c3c815244b697dffe81e0688c.zip |
setup-apkrepos: add option to add first mirror on the list
first in the list is normally a cdn
Diffstat (limited to 'setup-apkrepos.in')
-rw-r--r-- | setup-apkrepos.in | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in index 05ef08e..ed6cb8b 100644 --- a/setup-apkrepos.in +++ b/setup-apkrepos.in @@ -153,16 +153,21 @@ usage() { -f Detect and add fastest mirror -h Show this help -r Add a random mirror and do not prompt + -1 Add first mirror on the list (normally a CDN) __EOF__ exit 1 } -while getopts "fhr" opt; do +add_fastest=false +add_first=false +add_random=false +while getopts "1fhr" opt; do case $opt in - f) JUSTADDFASTEST=1;; + f) add_fastest=true;; + 1) add_first=true;; h) usage;; - r) JUSTADDRANDOM=1;; + r) add_random=true;; esac done shift $(($OPTIND - 1)) @@ -193,17 +198,21 @@ if [ $# -gt 0 ]; then # replace the apk repos with the specified ones rm -f "$APKREPOS_PATH" for i; do - echo "$i" >> "$APKREPOS_PATH" + echo "$i" >> "$APKREPOS_PATH" && changed=true done - changed=true fi -if [ -n "$JUSTADDRANDOM" ]; then +if $add_first; then + set -- $MIRRORS + add_mirror "$1" && changed=true +fi + +if $add_random; then show_mirror_list > /dev/null add_random_mirror && changed=true fi -if [ -n "$JUSTADDFASTEST" ]; then +if $add_fastest; then show_mirror_list > /dev/null add_fastest_mirror && changed=true fi |