mirror of
https://github.com/dockur/windows.git
synced 2024-11-15 01:34:41 +00:00
feat: Show download progress (#126)
This commit is contained in:
parent
8207169089
commit
2016dc8422
@ -185,8 +185,7 @@ abortInstall() {
|
|||||||
|
|
||||||
startInstall() {
|
startInstall() {
|
||||||
|
|
||||||
local magic desc
|
html "Starting Windows..."
|
||||||
local msg="Windows is being started, please wait..."
|
|
||||||
|
|
||||||
if [ -f "$STORAGE/$CUSTOM" ]; then
|
if [ -f "$STORAGE/$CUSTOM" ]; then
|
||||||
|
|
||||||
@ -207,36 +206,24 @@ startInstall() {
|
|||||||
|
|
||||||
BASE="$VERSION.iso"
|
BASE="$VERSION.iso"
|
||||||
|
|
||||||
if ! skipInstall && [ ! -f "$STORAGE/$BASE" ]; then
|
|
||||||
|
|
||||||
desc=$(printVersion "$VERSION")
|
|
||||||
[ -z "$desc" ] && desc="Windows"
|
|
||||||
msg="$desc is being downloaded, please wait..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
BASE=$(basename "${VERSION%%\?*}")
|
BASE=$(basename "${VERSION%%\?*}")
|
||||||
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
||||||
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
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..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "${BASE,,}" == "custom."* ]] && BASE="windows.iso"
|
[[ "${BASE,,}" == "custom."* ]] && BASE="windows.iso"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
html "$msg"
|
|
||||||
|
|
||||||
[ -z "$MANUAL" ] && MANUAL="N"
|
[ -z "$MANUAL" ] && MANUAL="N"
|
||||||
|
|
||||||
if [ -f "$STORAGE/$BASE" ]; then
|
if [ -f "$STORAGE/$BASE" ]; then
|
||||||
|
|
||||||
# Check if the ISO was already processed by our script
|
# 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=$(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')"
|
magic="$(printf '%s' "$magic" | od -A n -t x1 -v | tr -d ' \n')"
|
||||||
|
|
||||||
@ -277,22 +264,35 @@ downloadImage() {
|
|||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
local progress
|
local file="$iso"
|
||||||
|
local desc="$BASE"
|
||||||
|
local rc progress
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
cd "$TMP"
|
file="$iso.PART"
|
||||||
if ! /run/mido.sh "$url"; then
|
desc=$(printVersion "$VERSION")
|
||||||
return 1
|
[ -z "$desc" ] && desc="Windows"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local msg="Downloading $desc..."
|
||||||
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
|
/run/progress.sh "$file" "Downloading $desc ([P])..." &
|
||||||
|
|
||||||
|
if [[ "$EXTERNAL" != [Yy1]* ]]; then
|
||||||
|
|
||||||
|
cd "$TMP"
|
||||||
|
{ /run/mido.sh "$url"; rc=$?; } || :
|
||||||
cd /run
|
cd /run
|
||||||
|
|
||||||
[ ! -f "$iso" ] && return 1
|
fKill "progress.sh"
|
||||||
return 0
|
(( rc != 0 )) && return 1
|
||||||
fi
|
|
||||||
|
|
||||||
info "Downloading $BASE as boot image..."
|
else
|
||||||
|
|
||||||
# Check if running with interactive TTY or redirected to docker log
|
# Check if running with interactive TTY or redirected to docker log
|
||||||
if [ -t 1 ]; then
|
if [ -t 1 ]; then
|
||||||
@ -302,9 +302,15 @@ downloadImage() {
|
|||||||
fi
|
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"
|
||||||
(( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60
|
(( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
[ ! -f "$iso" ] && return 1
|
[ ! -f "$iso" ] && return 1
|
||||||
|
|
||||||
|
html "Download finished successfully..."
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user