diff --git a/src/config.sh b/src/config.sh index 7d35879..bece9f9 100644 --- a/src/config.sh +++ b/src/config.sh @@ -35,9 +35,7 @@ fi # Check available memory as the very last step RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}') -RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}') AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 )) -TOTAL_GB=$(( (RAM_TOTAL + 1073741823)/1073741824 )) if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value." diff --git a/src/install.sh b/src/install.sh index 17db3ab..ab476c1 100644 --- a/src/install.sh +++ b/src/install.sh @@ -31,7 +31,7 @@ rm -f "$TMP" MSG="Downloading $BASE..." info "$MSG" && html "$MSG" -/run/progress.sh "$TMP" "Downloading $BASE ([P])..." & +/run/progress.sh "$TMP" "" "Downloading $BASE ([P])..." & { wget "$BOOT" -O "$TMP" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || : fKill "progress.sh" diff --git a/src/progress.sh b/src/progress.sh index d32e272..e50d65e 100644 --- a/src/progress.sh +++ b/src/progress.sh @@ -12,7 +12,8 @@ escape () { } file="$1" -body=$(escape "$2") +total="$2" +body=$(escape "$3") info="/run/shm/msg.html" if [[ "$body" == *"..." ]]; then @@ -24,7 +25,12 @@ do if [ -s "$file" ]; then bytes=$(du -sb "$file" | cut -f1) if (( bytes > 1000 )); then - size=$(echo "$bytes" | numfmt --to=iec --suffix=B | sed -r 's/([A-Z])/ \1/') + if [ -z "$total" ] || [[ "$total" == "0" ]]; then + size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/') + else + size=$(printf '%.1f\n' "$((bytes*100*100/total))e-2") + size="$size%" + fi echo "${body//(\[P\])/($size)}"> "$info" fi fi