diff --git a/reinstall.sh b/reinstall.sh index 63cc6d3..b581a8c 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -205,15 +205,15 @@ test_url_real() { add_community_repo_for_alpine() { # 先检查原来的repo是不是egde - if grep -x 'http.*/edge/main' /etc/apk/repositories; then + if grep -q '^http.*/edge/main$' /etc/apk/repositories; then alpine_ver=edge else alpine_ver=v$(cut -d. -f1,2 >/etc/apk/repositories + if ! grep -q "^http.*/$alpine_ver/community$" /etc/apk/repositories; then + mirror=$(grep '^http.*/main$' /etc/apk/repositories | sed 's,/[^/]*/main$,,' | head -1) + echo $mirror/$alpine_ver/community >>/etc/apk/repositories fi } diff --git a/trans.sh b/trans.sh index 9809495..e358651 100644 --- a/trans.sh +++ b/trans.sh @@ -41,15 +41,15 @@ error_and_exit() { add_community_repo() { # 先检查原来的repo是不是egde - if grep -x 'http.*/edge/main' /etc/apk/repositories; then + if grep -q '^http.*/edge/main$' /etc/apk/repositories; then alpine_ver=edge else alpine_ver=v$(cut -d. -f1,2 >/etc/apk/repositories + if ! grep -q "^http.*/$alpine_ver/community$" /etc/apk/repositories; then + mirror=$(grep '^http.*/main$' /etc/apk/repositories | sed 's,/[^/]*/main$,,' | head -1) + echo $mirror/$alpine_ver/community >>/etc/apk/repositories fi }