Commit 0e82dc7c authored by Jeff Bilyk's avatar Jeff Bilyk

setup-apkrepos: add option to just add random mirror and don't prompt anymore

parent 2d20af0d
...@@ -120,6 +120,28 @@ edit_repositories() { ...@@ -120,6 +120,28 @@ edit_repositories() {
test "$(md5sum $APKREPOS_PATH)" != "$md5" 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 # main
# install alpine-mirrors if its not already there # install alpine-mirrors if its not already there
to_uninstall= to_uninstall=
...@@ -143,24 +165,31 @@ if [ -r "$APKREPOS_PATH" ]; then ...@@ -143,24 +165,31 @@ if [ -r "$APKREPOS_PATH" ]; then
APKREPOS=`cat "$APKREPOS_PATH"` APKREPOS=`cat "$APKREPOS_PATH"`
fi fi
get_alpine_release get_alpine_release
default_answer=f default_answer=f
changed= changed=
while true; do while true; do
show_mirror_list if [ -n "$JUSTADDRANDOM" ]; then
prompt_setup_method $default_answer show_mirror_list > /dev/null
add_random_mirror && changed=1 && break
default_read answer $default_answer else
case "$answer" in show_mirror_list
"done") break;; prompt_setup_method $default_answer
[0-9]*) add_from_list $answer && changed=1;;
/*|http://*|ftp://*|https://*) add_from_url "$answer" && changed=1;; default_read answer $default_answer
r) add_random_mirror && changed=1;; case "$answer" in
f) add_fastest_mirror && changed=1;; "done") break;;
e) edit_repositories && changed=1 && break;; [0-9]*) add_from_list $answer && changed=1;;
esac /*|http://*|ftp://*|https://*) add_from_url "$answer" && changed=1;;
if [ -n "$changed" ]; then r) add_random_mirror && changed=1;;
default_answer="done" f) add_fastest_mirror && changed=1;;
e) edit_repositories && changed=1 && break;;
esac
if [ -n "$changed" ]; then
default_answer="done"
fi
fi fi
done done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment