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
+19 -4
View File
@@ -33,17 +33,31 @@ 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
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
else
echo "Adding [aur-shield] to $PACMAN_CONF..."
sudo tee -a "$PACMAN_CONF" > /dev/null << EOF
@@ -51,6 +65,7 @@ else
$REPO_ENTRY
EOF
echo "✓ Added repo entry"
fi
fi
# Install safe-yay wrapper