feat: Additional mirrors
This commit is contained in:
parent
6265199cbb
commit
ed9a3199fa
1 changed files with 71 additions and 24 deletions
|
|
@ -2,8 +2,10 @@
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
: "${MANUAL:=""}"
|
: "${MANUAL:=""}"
|
||||||
|
: "${VERSION:=""}"
|
||||||
: "${DETECTED:=""}"
|
: "${DETECTED:=""}"
|
||||||
: "${VERSION:="win11arm64"}"
|
|
||||||
|
[ -z "$VERSION" ] && VERSION="win11arm64"
|
||||||
|
|
||||||
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
||||||
VERSION="${VERSION:1:-1}"
|
VERSION="${VERSION:1:-1}"
|
||||||
|
|
@ -284,13 +286,21 @@ downloadImage() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
local desc rc progress
|
local rc=99
|
||||||
|
local msg desc progress
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
|
||||||
|
# Check if running with interactive TTY or redirected to docker log
|
||||||
|
if [ -t 1 ]; then
|
||||||
|
progress="--progress=bar:noscroll"
|
||||||
|
else
|
||||||
|
progress="--progress=dot:giga"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
desc=$(printVersion "$VERSION" "Windows")
|
desc=$(printVersion "$VERSION" "Windows for ARM")
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|
@ -300,38 +310,75 @@ downloadImage() {
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
if ! getESD "$TMP/esd" "$iso"; then
|
url=""
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if getESD "$TMP/esd" "$iso"; then
|
||||||
url="$ESD_URL"
|
url="$ESD_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local msg="Downloading $desc..."
|
if [ -n "$url" ]; then
|
||||||
|
|
||||||
|
msg="Downloading $desc..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
|
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
|
||||||
|
|
||||||
# Check if running with interactive TTY or redirected to docker log
|
|
||||||
if [ -t 1 ]; then
|
|
||||||
progress="--progress=bar:noscroll"
|
|
||||||
else
|
|
||||||
progress="--progress=dot:giga"
|
|
||||||
fi
|
|
||||||
|
|
||||||
{ wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || :
|
{ wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || :
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
(( rc != 0 )) && error "Failed to download $url , reason: $rc" && return 1
|
|
||||||
|
|
||||||
if [ -f "$iso" ]; then
|
if (( rc == 0 )) && [ -f "$iso" ]; then
|
||||||
if [ $(stat -c%s "$iso") -gt 100000000 ]; then
|
if [ $(stat -c%s "$iso") -gt 100000000 ]; then
|
||||||
html "Download finished successfully..." && return 0
|
html "Download finished successfully..." && return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
error "Failed to download $url" && return 1
|
fi
|
||||||
|
|
||||||
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
|
case "${VERSION,,}" in
|
||||||
|
"win11${ARCHI,,}")
|
||||||
|
url="https://dl.bobpony.com/windows/11/en-us_windows_11_23h2_${ARCHI,,}.iso"
|
||||||
|
;;
|
||||||
|
"win10${ARCHI,,}")
|
||||||
|
url="https://dl.bobpony.com/windows/10/en-us_windows_10_22h2_${ARCHI,,}.iso"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
(( rc != 99 )) && error "Failed to download $url , reason: $rc"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
info "Failed to download $desc from Microsoft, will try another mirror now..."
|
||||||
|
|
||||||
|
rm -f "$iso"
|
||||||
|
rm -rf "$TMP"
|
||||||
|
mkdir -p "$TMP"
|
||||||
|
|
||||||
|
ISO="$TMP/$BASE"
|
||||||
|
iso="$ISO"
|
||||||
|
rm -f "$iso"
|
||||||
|
|
||||||
|
msg="Downloading $desc..."
|
||||||
|
info "$msg" && html "$msg"
|
||||||
|
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
|
||||||
|
|
||||||
|
{ wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || :
|
||||||
|
|
||||||
|
fKill "progress.sh"
|
||||||
|
|
||||||
|
if (( rc == 0 )) && [ -f "$iso" ]; then
|
||||||
|
if [ $(stat -c%s "$iso") -gt 100000000 ]; then
|
||||||
|
html "Download finished successfully..." && return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
(( rc != 99 )) && error "Failed to download $url , reason: $rc"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
extractESD() {
|
extractESD() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue