mirror of
https://github.com/dockur/windows.git
synced 2025-10-28 11:45:50 +00:00
fix: Improved download
This commit is contained in:
parent
26ec1de22b
commit
f5212897cd
1 changed files with 86 additions and 78 deletions
132
src/install.sh
132
src/install.sh
|
|
@ -386,7 +386,6 @@ startInstall() {
|
|||
getESD() {
|
||||
|
||||
local dir="$1"
|
||||
local file="$2"
|
||||
local winCatalog size
|
||||
|
||||
case "${VERSION,,}" in
|
||||
|
|
@ -449,35 +448,17 @@ getESD() {
|
|||
return 0
|
||||
}
|
||||
|
||||
downloadImage() {
|
||||
doMido() {
|
||||
|
||||
local iso="$1"
|
||||
local url="$2"
|
||||
local rc=99
|
||||
local msg desc progress
|
||||
local desc="$3"
|
||||
local rc
|
||||
|
||||
rm -f "$iso"
|
||||
rm -f "$iso.PART"
|
||||
|
||||
# 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
|
||||
|
||||
desc=$(printVersion "$VERSION" "Windows")
|
||||
|
||||
else
|
||||
|
||||
desc=$(getName "$BASE" "$BASE")
|
||||
|
||||
fi
|
||||
|
||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||
|
||||
msg="Downloading $desc..."
|
||||
local msg="Downloading $desc..."
|
||||
info "$msg" && html "$msg"
|
||||
/run/progress.sh "$iso.PART" "Downloading $desc ([P])..." &
|
||||
|
||||
|
|
@ -493,32 +474,29 @@ downloadImage() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if [[ "$VERSION" != "win10x64" ]] && [[ "$VERSION" != "win11x64" ]]; then
|
||||
rm -f "$iso"
|
||||
rm -f "$iso.PART"
|
||||
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
info "Failed to download $desc using Mido, will try a different method now..."
|
||||
downloadFile() {
|
||||
|
||||
local iso="$1"
|
||||
local url="$2"
|
||||
local desc="$3"
|
||||
local rc progress
|
||||
|
||||
rm -f "$iso"
|
||||
rm -rf "$TMP"
|
||||
mkdir -p "$TMP"
|
||||
|
||||
rc=99
|
||||
ISO="$TMP/$VERSION.esd"
|
||||
iso="$ISO"
|
||||
rm -f "$iso"
|
||||
|
||||
url=""
|
||||
|
||||
if getESD "$TMP/esd" "$iso"; then
|
||||
url="$ESD_URL"
|
||||
# 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
|
||||
|
||||
fi
|
||||
|
||||
if [ -n "$url" ]; then
|
||||
|
||||
msg="Downloading $desc..."
|
||||
local msg="Downloading $desc..."
|
||||
info "$msg" && html "$msg"
|
||||
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
|
||||
|
||||
|
|
@ -532,10 +510,58 @@ downloadImage() {
|
|||
fi
|
||||
fi
|
||||
|
||||
rm -f "$iso"
|
||||
error "Failed to download $url , reason: $rc"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
downloadImage() {
|
||||
|
||||
local iso="$1"
|
||||
local url="$2"
|
||||
local rc desc
|
||||
|
||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||
|
||||
desc=$(printVersion "$VERSION" "Windows")
|
||||
|
||||
else
|
||||
|
||||
desc=$(getName "$BASE" "$BASE")
|
||||
|
||||
fi
|
||||
|
||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||
|
||||
doMido "$iso" "$url" "$desc" && return 0
|
||||
|
||||
if [[ "$VERSION" != "win10${PLATFORM,,}" ]] && [[ "$VERSION" != "win11${PLATFORM,,}" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
info "Failed to download $desc using Mido, will try a different method now..."
|
||||
|
||||
rm -rf "$TMP"
|
||||
mkdir -p "$TMP"
|
||||
|
||||
ISO="$TMP/$VERSION.esd"
|
||||
iso="$ISO"
|
||||
|
||||
if ! getESD "$TMP/esd"; then
|
||||
url=""
|
||||
else
|
||||
url="$ESD_URL"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ -n "$url" ]; then
|
||||
downloadFile "$iso" "$url" "$desc" && return 0
|
||||
fi
|
||||
|
||||
[[ "$EXTERNAL" == [Yy1]* ]] && return 1
|
||||
|
||||
case "${VERSION,,}" in
|
||||
"win11${PLATFORM,,}")
|
||||
url="https://dl.bobpony.com/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
|
||||
|
|
@ -544,38 +570,20 @@ downloadImage() {
|
|||
url="https://dl.bobpony.com/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.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])..." &
|
||||
downloadFile "$iso" "$url" "$desc" && return 0
|
||||
|
||||
{ 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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue