From 1f67f6f976c07427b411e0eed65b3858af502e73 Mon Sep 17 00:00:00 2001 From: arch_agent Date: Tue, 4 Aug 2026 11:35:52 +0200 Subject: [PATCH] fix: installer detects scan-only server and skips pacman repo - Queries /api/status for scan_only flag - Scan-only: no [aur-shield] in pacman.conf, removes stale entry if present - Full mode: adds/updates repo as before - No more pacman sync errors when LAN server is offline --- install-client.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/install-client.sh b/install-client.sh index e99a229..d0b9638 100644 --- a/install-client.sh +++ b/install-client.sh @@ -33,24 +33,39 @@ SHIELD_PORT="$SHIELD_PORT" EOFCONF echo "✓ Config written to /etc/safe-yay.conf" -# Add pacman repo +# Add pacman repo (skip if scan-only server — no repo needed) +# Check if server is scan-only by querying status +SERVER_SCAN_ONLY=$(curl -sf "http://$SHIELD_HOST:$SHIELD_PORT/api/status" 2>/dev/null | python3 -c "import sys,json; print(json.loads(sys.stdin.read()).get('scan_only',False))" 2>/dev/null || echo False) + PACMAN_CONF="/etc/pacman.conf" -REPO_ENTRY="[aur-shield] + +if [ "$SERVER_SCAN_ONLY" = True ]; then + echo "✓ Scan-Only Server erkannt — kein pacman repo nötig (client baut lokal)" + # Remove aur-shield repo if it exists from a previous full-mode install + if grep -q "^\[aur-shield\]" "$PACMAN_CONF"; then + echo " Entferne veralteten [aur-shield] Eintrag aus pacman.conf..." + sudo sed -i '/^\[aur-shield\]/,/^\[/{/^\[aur-shield\]/d; /^\[/!d}' "$PACMAN_CONF" + sudo sed -i '/^# AUR-Shield/d' "$PACMAN_CONF" + echo " ✓ Entfernt" + fi +else + REPO_ENTRY="[aur-shield] Server = http://$SHIELD_HOST:$SHIELD_PORT/repo SigLevel = Never" -if grep -q "^\[aur-shield\]" "$PACMAN_CONF"; then - echo "⚠ [aur-shield] already exists — updating server URL..." - sudo sed -i "/^\[aur-shield\]/,/^\[/ s|Server = .*|Server = http://$SHIELD_HOST:$SHIELD_PORT/repo|" "$PACMAN_CONF" - echo "✓ Updated repo server URL" -else - echo "Adding [aur-shield] to $PACMAN_CONF..." - sudo tee -a "$PACMAN_CONF" > /dev/null << EOF + if grep -q "^\[aur-shield\]" "$PACMAN_CONF"; then + echo "⚠ [aur-shield] already exists — updating server URL..." + sudo sed -i "/^\[aur-shield\]/,/^\[/ s|Server = .*|Server = http://$SHIELD_HOST:$SHIELD_PORT/repo|" "$PACMAN_CONF" + echo "✓ Updated repo server URL" + else + echo "Adding [aur-shield] to $PACMAN_CONF..." + sudo tee -a "$PACMAN_CONF" > /dev/null << EOF # AUR-Shield — AI-scanned AUR packages $REPO_ENTRY EOF - echo "✓ Added repo entry" + echo "✓ Added repo entry" + fi fi # Install safe-yay wrapper