diff options
| -rw-r--r-- | releng/airootfs/etc/systemd/system/chaotic-rankmirrors.service | 2 | ||||
| -rwxr-xr-x | releng/airootfs/usr/local/bin/chaotic-rankmirrors | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/releng/airootfs/etc/systemd/system/chaotic-rankmirrors.service b/releng/airootfs/etc/systemd/system/chaotic-rankmirrors.service index d0d3a03..5805163 100644 --- a/releng/airootfs/etc/systemd/system/chaotic-rankmirrors.service +++ b/releng/airootfs/etc/systemd/system/chaotic-rankmirrors.service @@ -5,7 +5,7 @@ After=network-online.target [Service] Type=oneshot -ExecStart=/usr/local/bin/chaotic-rankmirrors +ExecStart=-/usr/local/bin/chaotic-rankmirrors [Install] WantedBy=multi-user.target diff --git a/releng/airootfs/usr/local/bin/chaotic-rankmirrors b/releng/airootfs/usr/local/bin/chaotic-rankmirrors index 71c256e..931d923 100755 --- a/releng/airootfs/usr/local/bin/chaotic-rankmirrors +++ b/releng/airootfs/usr/local/bin/chaotic-rankmirrors @@ -36,19 +36,22 @@ if [ ! -s "$tmp" ]; then exit 0 fi -mapfile -t top < <(sort -n "$tmp" | head -n "$TOP_N") +sorted=$(sort -n "$tmp") rm -f "$tmp" cp "$MIRRORLIST" "${MIRRORLIST}.bak" 2>/dev/null || true +count=0 { echo "# Chaotic-AUR mirrorlist" echo "# Generated by chaotic-rankmirrors on $(date)" echo "" - for e in "${top[@]}"; do + while IFS= read -r e; do + [ "$count" -ge "$TOP_N" ] && break m="${e#* }" echo "Server = https://${m}.chaotic.cx/\$repo/\$arch" - done + count=$((count + 1)) + done <<< "$sorted" } > "$MIRRORLIST" -echo "==> Done. Updated mirrorlist with ${#top[@]} fastest mirrors." +echo "==> Done. Updated mirrorlist with ${count} fastest mirrors." |