From 15899d04537375914dd097c2f30e0f893a5c33c0 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Jan 2024 04:12:04 +0100 Subject: [PATCH 1/4] feat: Show download progress --- src/install.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/install.sh b/src/install.sh index cfaa2f232..638df2113 100644 --- a/src/install.sh +++ b/src/install.sh @@ -211,7 +211,7 @@ startInstall() { desc=$(printVersion "$VERSION") [ -z "$desc" ] && desc="Windows" - msg="$desc is being downloaded, please wait..." + msg="Downloading $desc..." fi else @@ -221,7 +221,7 @@ startInstall() { BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g') if ! skipInstall && [ ! -f "$STORAGE/$BASE" ]; then - msg="Image '$BASE' is being downloaded, please wait..." + msg="Downloading $BASE ..." fi fi @@ -277,22 +277,35 @@ downloadImage() { local iso="$1" local url="$2" - local progress + local msg desc progress + local finish="Download finished successfully..." + rm -f "$iso" if [[ "$EXTERNAL" != [Yy1]* ]]; then + desc=$(printVersion "$VERSION") + [ -z "$desc" ] && desc="Windows" + msg="Downloading $desc..." + info "$msg" && html "$msg" + /run/progress.sh "$iso.PART" "Downloading $desc ([P])..." & + cd "$TMP" if ! /run/mido.sh "$url"; then + fKill "progress.sh" return 1 fi cd /run + fKill "progress.sh" [ ! -f "$iso" ] && return 1 + + html "$finish" return 0 fi - info "Downloading $BASE as boot image..." + msg="Downloading $BASE ..." + info "$msg" && html "$msg" # Check if running with interactive TTY or redirected to docker log if [ -t 1 ]; then @@ -301,10 +314,14 @@ downloadImage() { progress="--progress=dot:giga" fi + /run/progress.sh "$iso" "Downloading $BASE ([P])..." & { wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || : - (( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60 + fKill "progress.sh" + (( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60 [ ! -f "$iso" ] && return 1 + + html "$finish" return 0 } From 8792ea048988ca7297573a510d446438bc63d7df Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Jan 2024 04:17:07 +0100 Subject: [PATCH 2/4] Update install.sh --- src/install.sh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/install.sh b/src/install.sh index 638df2113..b303c6c95 100644 --- a/src/install.sh +++ b/src/install.sh @@ -185,8 +185,7 @@ abortInstall() { startInstall() { - local magic desc - local msg="Windows is being started, please wait..." + html "Starting Windows..." if [ -f "$STORAGE/$CUSTOM" ]; then @@ -207,36 +206,24 @@ startInstall() { BASE="$VERSION.iso" - if ! skipInstall && [ ! -f "$STORAGE/$BASE" ]; then - - desc=$(printVersion "$VERSION") - [ -z "$desc" ] && desc="Windows" - msg="Downloading $desc..." - fi - else BASE=$(basename "${VERSION%%\?*}") : "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}" BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g') - if ! skipInstall && [ ! -f "$STORAGE/$BASE" ]; then - msg="Downloading $BASE ..." - fi - fi [[ "${BASE,,}" == "custom."* ]] && BASE="windows.iso" fi - html "$msg" - [ -z "$MANUAL" ] && MANUAL="N" if [ -f "$STORAGE/$BASE" ]; then # Check if the ISO was already processed by our script + local magic="" magic=$(dd if="$STORAGE/$BASE" seek=0 bs=1 count=1 status=none | tr -d '\000') magic="$(printf '%s' "$magic" | od -A n -t x1 -v | tr -d ' \n')" From eaeb1c8d12565eaa09bccec59ebbcb9077017ded Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Jan 2024 04:30:39 +0100 Subject: [PATCH 3/4] Update install.sh --- src/install.sh | 56 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/install.sh b/src/install.sh index b303c6c95..5fc75ccc8 100644 --- a/src/install.sh +++ b/src/install.sh @@ -264,51 +264,53 @@ downloadImage() { local iso="$1" local url="$2" - local msg desc progress - local finish="Download finished successfully..." + local file="$iso" + local desc="$BASE" + local rc progress rm -f "$iso" - + if [[ "$EXTERNAL" != [Yy1]* ]]; then + file="$iso.PART" desc=$(printVersion "$VERSION") [ -z "$desc" ] && desc="Windows" - msg="Downloading $desc..." - info "$msg" && html "$msg" - /run/progress.sh "$iso.PART" "Downloading $desc ([P])..." & + + fi + + local msg="Downloading $desc..." + info "$msg" && html "$msg" + + /run/progress.sh "$file" "Downloading $desc ([P])..." & + + if [[ "$EXTERNAL" != [Yy1]* ]]; then cd "$TMP" - if ! /run/mido.sh "$url"; then - fKill "progress.sh" - return 1 - fi + { /run/mido.sh "$url"; rc=$?; } || : cd /run fKill "progress.sh" - [ ! -f "$iso" ] && return 1 + (( rc != 0 )) && return 1 - html "$finish" - return 0 - fi + else - msg="Downloading $BASE ..." - info "$msg" && html "$msg" + # 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 - # 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=$?; } || : - /run/progress.sh "$iso" "Downloading $BASE ([P])..." & - { wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || : + fKill "progress.sh" + (( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60 + + fi - fKill "progress.sh" - (( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60 [ ! -f "$iso" ] && return 1 - html "$finish" + html "Download finished successfully..." return 0 } From 5bb268a2768d9a2d9a6b41291626452d8594381a Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Jan 2024 04:31:44 +0100 Subject: [PATCH 4/4] Update install.sh --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index 5fc75ccc8..2557d3e42 100644 --- a/src/install.sh +++ b/src/install.sh @@ -269,7 +269,7 @@ downloadImage() { local rc progress rm -f "$iso" - + if [[ "$EXTERNAL" != [Yy1]* ]]; then file="$iso.PART"