diff --git a/src/define.sh b/src/define.sh index fd6a128..24d5f79 100644 --- a/src/define.sh +++ b/src/define.sh @@ -291,7 +291,7 @@ printVersion() { if [ -z "$desc" ]; then desc="Windows" - [[ "${PLATFORM,,}" != "x64" ]] && desc="$desc for ${PLATFORM}" + [[ "${PLATFORM,,}" != "x64" ]] && desc+=" for ${PLATFORM}" fi echo "$desc" @@ -326,7 +326,7 @@ printEdition() { ;; esac - [ -n "$edition" ] && result="$result $edition" + [ -n "$edition" ] && result+=" $edition" echo "$result" return 0 diff --git a/src/install.sh b/src/install.sh index bd56f6f..0aada6e 100644 --- a/src/install.sh +++ b/src/install.sh @@ -167,10 +167,13 @@ abortInstall() { local dir="$1" local iso="$2" + local efi [[ "${iso,,}" == *".esd" ]] && exit 60 - if [ ! -d "$dir/EFI" ]; then + efi=$(find "$dir" -maxdepth 1 -type d -iname efi | head -n 1) + + if [ -z "$efi" ]; then [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy" fi @@ -557,7 +560,7 @@ detectImage() { if [[ "${LANGUAGE,,}" != "en" ]] && [[ "${LANGUAGE,,}" != "en-"* ]]; then language=$(getLanguage "$LANGUAGE" "desc") - desc="$desc ($language)" + desc=+" ($language)" fi info "Detected: $desc" @@ -669,7 +672,7 @@ addDriver() { "win81x64"* ) folder="w8.1/amd64" ;; "win10x64"* ) folder="w10/amd64" ;; "win11x64"* ) folder="w11/amd64" ;; - "win2025"* ) folder="2k22/amd64" ;; + "win2025"* ) folder="w11/amd64" ;; "win2022"* ) folder="2k22/amd64" ;; "win2019"* ) folder="2k19/amd64" ;; "win2016"* ) folder="2k16/amd64" ;; diff --git a/src/mido.sh b/src/mido.sh index 3287874..00236f6 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -69,8 +69,11 @@ getESD() { local fFile="products_filter.xml" { wget "$winCatalog" -O "$dir/$wFile" -q --timeout=30; rc=$?; } || : - (( rc == 4 )) && error "Failed to download $winCatalog , network failure!" && return 1 - (( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1 + + msg="Failed to download $winCatalog" + (( rc == 4 )) && error "$msg , network failure!" && return 1 + (( rc == 8 )) && error "$msg , server issued an error response!" && return 1 + (( rc != 0 )) && error "$msg , reason: $rc" && return 1 cd "$dir" @@ -148,8 +151,6 @@ verifyFile() { fi error "The downloaded file has an invalid $algo checksum: $hash , while expected value was: $check. Please report this at $SUPPORT/issues" - - rm -f "$iso" return 1 } @@ -172,19 +173,19 @@ downloadFile() { progress="--progress=dot:giga" fi - local msg="Downloading $desc..." - html "$msg" + local msg="Downloading $desc" + html "$msg..." domain=$(echo "$url" | awk -F/ '{print $3}') dots=$(echo "$domain" | tr -cd '.' | wc -c) (( dots > 1 )) && domain=$(expr "$domain" : '.*\.\(.*\..*\)') if [ -n "$domain" ] && [[ "${domain,,}" != *"microsoft.com" ]]; then - msg="Downloading $desc from $domain..." + msg="Downloading $desc from $domain" fi - info "$msg" - /run/progress.sh "$iso" "$size" "Downloading $desc ([P])..." & + info "$msg..." + /run/progress.sh "$iso" "$size" "$msg ([P])..." & { wget "$url" -O "$iso" -q --timeout=30 --show-progress "$progress"; rc=$?; } || : @@ -192,19 +193,18 @@ downloadFile() { if (( rc == 0 )) && [ -f "$iso" ]; then total=$(stat -c%s "$iso") - if [ "$total" -gt 100000000 ]; then - ! verifyFile "$iso" "$size" "$total" "$sum" && return 1 - html "Download finished successfully..." && return 0 + if [ "$total" -lt 100000000 ]; then + error "Downloaded ISO is only $total bytes?" && return 1 fi + ! verifyFile "$iso" "$size" "$total" "$sum" && return 1 + html "Download finished successfully..." && return 0 fi - if (( rc != 4 )); then - error "Failed to download $url , reason: $rc" - else - error "Failed to download $url , network failure!" - fi + msg="Failed to download $url" + (( rc == 4 )) && error "$msg , network failure!" && return 1 + (( rc == 8 )) && error "$msg , server issued an error response!" && return 1 - rm -f "$iso" + error "$msg , reason: $rc" return 1 } @@ -220,6 +220,7 @@ downloadImage() { base=$(basename "$iso") desc=$(fromFile "$base") downloadFile "$iso" "$version" "" "" "" "$desc" && return 0 + rm -f "$iso" return 1 fi @@ -235,7 +236,7 @@ downloadImage() { desc=$(printEdition "$version" "$desc") error "The $language language version of $desc is not available, please switch to English." && return 1 fi - desc="$desc in $language" + desc+=" in $language" fi switchEdition "$version" @@ -251,6 +252,7 @@ downloadImage() { if getESD "$TMP/esd" "$version" "$lang" "$desc"; then ISO="${ISO%.*}.esd" downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0 + rm -f "$ISO" ISO="$iso" fi @@ -268,6 +270,7 @@ downloadImage() { size=$(getSize "$i" "$version" "$lang") sum=$(getHash "$i" "$version" "$lang") downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0 + rm -f "$iso" fi done diff --git a/src/power.sh b/src/power.sh index ecc65ff..f94360f 100644 --- a/src/power.sh +++ b/src/power.sh @@ -199,7 +199,7 @@ _graceful_shutdown() { SERIAL="pty" MONITOR="telnet:localhost:$QEMU_PORT,server,nowait,nodelay" -MONITOR="$MONITOR -daemonize -D $QEMU_LOG -pidfile $QEMU_PID" +MONITOR+=" -daemonize -D $QEMU_LOG -pidfile $QEMU_PID" _trap _graceful_shutdown SIGTERM SIGHUP SIGINT SIGABRT SIGQUIT