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
This commit is contained in:
arch_agent
2026-08-04 11:35:52 +02:00
parent 599aca907d
commit 1f67f6f976
+16 -1
View File
@@ -33,8 +33,22 @@ SHIELD_PORT="$SHIELD_PORT"
EOFCONF EOFCONF
echo "✓ Config written to /etc/safe-yay.conf" 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" PACMAN_CONF="/etc/pacman.conf"
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] REPO_ENTRY="[aur-shield]
Server = http://$SHIELD_HOST:$SHIELD_PORT/repo Server = http://$SHIELD_HOST:$SHIELD_PORT/repo
SigLevel = Never" SigLevel = Never"
@@ -52,6 +66,7 @@ $REPO_ENTRY
EOF EOF
echo "✓ Added repo entry" echo "✓ Added repo entry"
fi fi
fi
# Install safe-yay wrapper # Install safe-yay wrapper
WRAPPER_PATH="/usr/local/bin/safe-yay" WRAPPER_PATH="/usr/local/bin/safe-yay"