feat: Improved download
This commit is contained in:
parent
ed9a3199fa
commit
3ebd8fcc9c
1 changed files with 57 additions and 64 deletions
121
src/install.sh
121
src/install.sh
|
|
@ -29,7 +29,7 @@ if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ESD_URL=""
|
ESD_URL=""
|
||||||
ARCHI="ARM64"
|
PLATFORM="ARM64"
|
||||||
TMP="$STORAGE/tmp"
|
TMP="$STORAGE/tmp"
|
||||||
DIR="$TMP/unpack"
|
DIR="$TMP/unpack"
|
||||||
FB="falling back to manual installation!"
|
FB="falling back to manual installation!"
|
||||||
|
|
@ -219,14 +219,13 @@ startInstall() {
|
||||||
getESD() {
|
getESD() {
|
||||||
|
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
local file="$2"
|
|
||||||
local winCatalog size
|
local winCatalog size
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${VERSION,,}" in
|
||||||
"win11${ARCHI,,}")
|
"win11${PLATFORM,,}")
|
||||||
winCatalog="https://go.microsoft.com/fwlink?linkid=2156292"
|
winCatalog="https://go.microsoft.com/fwlink?linkid=2156292"
|
||||||
;;
|
;;
|
||||||
"win10${ARCHI,,}")
|
"win10${PLATFORM,,}")
|
||||||
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
|
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
@ -260,7 +259,7 @@ getESD() {
|
||||||
|
|
||||||
local esdLang="en-us"
|
local esdLang="en-us"
|
||||||
local editionName="Professional"
|
local editionName="Professional"
|
||||||
local edQuery='//File[Architecture="'${ARCHI}'"][Edition="'${editionName}'"]'
|
local edQuery='//File[Architecture="'${PLATFORM}'"][Edition="'${editionName}'"]'
|
||||||
|
|
||||||
echo -e '<Catalog>' > "${dir}/products_filter.xml"
|
echo -e '<Catalog>' > "${dir}/products_filter.xml"
|
||||||
xmllint --nonet --xpath "${edQuery}" "${dir}/products.xml" >> "${dir}/products_filter.xml" 2>/dev/null
|
xmllint --nonet --xpath "${edQuery}" "${dir}/products.xml" >> "${dir}/products_filter.xml" 2>/dev/null
|
||||||
|
|
@ -282,12 +281,12 @@ getESD() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadImage() {
|
downloadFile() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
local rc=99
|
local desc="$3"
|
||||||
local msg desc progress
|
local rc progress
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
|
||||||
|
|
@ -298,6 +297,32 @@ downloadImage() {
|
||||||
progress="--progress=dot:giga"
|
progress="--progress=dot:giga"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local 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
|
||||||
|
|
||||||
|
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
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
desc=$(printVersion "$VERSION" "Windows for ARM")
|
desc=$(printVersion "$VERSION" "Windows for ARM")
|
||||||
|
|
@ -310,74 +335,42 @@ downloadImage() {
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
url=""
|
if ! getESD "$TMP/esd"; then
|
||||||
|
url=""
|
||||||
if getESD "$TMP/esd" "$iso"; then
|
else
|
||||||
url="$ESD_URL"
|
url="$ESD_URL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$url" ]; then
|
if [ -n "$url" ]; then
|
||||||
|
downloadFile "$iso" "$url" "$desc" && return 0
|
||||||
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
|
fi
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
[[ "$EXTERNAL" == [Yy1]* ]] && return 1
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${VERSION,,}" in
|
||||||
"win11${ARCHI,,}")
|
"win11${PLATFORM,,}")
|
||||||
url="https://dl.bobpony.com/windows/11/en-us_windows_11_23h2_${ARCHI,,}.iso"
|
url="https://dl.bobpony.com/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
|
||||||
;;
|
;;
|
||||||
"win10${ARCHI,,}")
|
"win10${PLATFORM,,}")
|
||||||
url="https://dl.bobpony.com/windows/10/en-us_windows_10_22h2_${ARCHI,,}.iso"
|
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
|
||||||
return 1
|
;;
|
||||||
;;
|
esac
|
||||||
esac
|
|
||||||
|
|
||||||
info "Failed to download $desc from Microsoft, will try another mirror now..."
|
info "Failed to download $desc from Microsoft, will try another mirror now..."
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -rf "$TMP"
|
||||||
rm -rf "$TMP"
|
mkdir -p "$TMP"
|
||||||
mkdir -p "$TMP"
|
|
||||||
|
|
||||||
ISO="$TMP/$BASE"
|
ISO="$TMP/$BASE"
|
||||||
iso="$ISO"
|
iso="$ISO"
|
||||||
rm -f "$iso"
|
|
||||||
|
|
||||||
msg="Downloading $desc..."
|
downloadFile "$iso" "$url" "$desc" && return 0
|
||||||
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
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -440,10 +433,10 @@ extractESD() {
|
||||||
local edition imageIndex imageEdition
|
local edition imageIndex imageEdition
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${VERSION,,}" in
|
||||||
"win11${ARCHI,,}")
|
"win11${PLATFORM,,}")
|
||||||
edition="11 pro"
|
edition="11 pro"
|
||||||
;;
|
;;
|
||||||
"win10${ARCHI,,}")
|
"win10${PLATFORM,,}")
|
||||||
edition="10 pro"
|
edition="10 pro"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue