diff options
author | Jeff Bilyk <jbilyk@gmail.com> | 2011-08-06 17:54:18 -0400 |
---|---|---|
committer | Jeff Bilyk <jbilyk@gmail.com> | 2011-08-06 17:54:18 -0400 |
commit | 0e82dc7cb5563ce62cbfe3c17cad6ec547c159ac (patch) | |
tree | fef010cba74e03e496234f0930071cbc1dd2adae /setup-apkrepos.in | |
parent | 2d20af0dea81fb6827933b87d15608a68026fd29 (diff) | |
download | alpine-conf-0e82dc7cb5563ce62cbfe3c17cad6ec547c159ac.zip |
setup-apkrepos: add option to just add random mirror and don't prompt anymore
Diffstat (limited to 'setup-apkrepos.in')
-rwxr-xr-x | setup-apkrepos.in | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in index d4e8d80..49214f3 100755 --- a/setup-apkrepos.in +++ b/setup-apkrepos.in @@ -120,6 +120,28 @@ edit_repositories() { test "$(md5sum $APKREPOS_PATH)" != "$md5" } +usage() { + cat <<__EOF__ +usage: setup-apkrepos [-hr] + +Setup apk repositories + +options: + -h Show this help + -r Add a random mirror and do not prompt +__EOF__ + exit 1 + +} + +while getopts "hr" opt; do + case $opt in + h) usage;; + r) JUSTADDRANDOM=1;; + esac +done + + # main # install alpine-mirrors if its not already there to_uninstall= @@ -143,24 +165,31 @@ if [ -r "$APKREPOS_PATH" ]; then APKREPOS=`cat "$APKREPOS_PATH"` fi + + get_alpine_release default_answer=f changed= while true; do - show_mirror_list - prompt_setup_method $default_answer - - default_read answer $default_answer - case "$answer" in - "done") break;; - [0-9]*) add_from_list $answer && changed=1;; - /*|http://*|ftp://*|https://*) add_from_url "$answer" && changed=1;; - r) add_random_mirror && changed=1;; - f) add_fastest_mirror && changed=1;; - e) edit_repositories && changed=1 && break;; - esac - if [ -n "$changed" ]; then - default_answer="done" + if [ -n "$JUSTADDRANDOM" ]; then + show_mirror_list > /dev/null + add_random_mirror && changed=1 && break + else + show_mirror_list + prompt_setup_method $default_answer + + default_read answer $default_answer + case "$answer" in + "done") break;; + [0-9]*) add_from_list $answer && changed=1;; + /*|http://*|ftp://*|https://*) add_from_url "$answer" && changed=1;; + r) add_random_mirror && changed=1;; + f) add_fastest_mirror && changed=1;; + e) edit_repositories && changed=1 && break;; + esac + if [ -n "$changed" ]; then + default_answer="done" + fi fi done |