Added progress bar for nikki update

This commit is contained in:
Sam 2026-11-14 02:41:29 +08:00
parent 180d3a2650
commit 2561d0b5d4

View File

@ -67,7 +67,7 @@ while read -r name url; do
d=$work/b
rm -rf "$d"
mkdir -p "$d"
curl -fsSL --connect-timeout 20 -m 600 --retry 3 "$url" | tar xzf - -C "$d"
curl -fSL --connect-timeout 20 -m 600 --retry 3 --progress-bar "$url" | tar xzf - -C "$d"
[ -f "$d/Packages.gz" ] && [ -f "$d/Packages.sig" ] || { echo "$name: not a feed" >&2; exit 1; }
rm -f "$d"/mihomo-alpha_*.ipk "$d"/luci-i18n-nikki-zh-*.ipk
# ustar, no owner names: busybox tar on the router
@ -76,8 +76,11 @@ while read -r name url; do
ok=
for try in 1 2 3; do
echo "$name: uploading $(du -h "$work/$name" | cut -f1) (try $try)"
gitea -m 600 -X POST -F "attachment=@$work/$name" \
"$api/releases/$id/assets?name=$name" > /dev/null || true
# progress bar on the terminal, then the average speed
curl -K "$work/curlrc" -fS --connect-timeout 20 -m 600 --progress-bar -o /dev/null \
-w '%{time_total} %{speed_upload}\n' \
-X POST -F "attachment=@$work/$name" "$api/releases/$id/assets?name=$name" |
awk -v n="$name" '{printf "%s: sent in %ds, %.2f MB/s\n", n, $1, $2 / 1048576}' || true
# what the server has now: right size = done, anything else = remove and retry
gitea -m 60 "$api/releases/$id/assets" > "$work/assets.json" || continue
jq -r --arg n "$name" --argjson s "$size" '.[] | select(.name == $n) |