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:
+25
-10
@@ -33,24 +33,39 @@ 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"
|
||||||
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
|
Server = http://$SHIELD_HOST:$SHIELD_PORT/repo
|
||||||
SigLevel = Never"
|
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..."
|
echo "⚠ [aur-shield] already exists — updating server URL..."
|
||||||
sudo sed -i "/^\[aur-shield\]/,/^\[/ s|Server = .*|Server = http://$SHIELD_HOST:$SHIELD_PORT/repo|" "$PACMAN_CONF"
|
sudo sed -i "/^\[aur-shield\]/,/^\[/ s|Server = .*|Server = http://$SHIELD_HOST:$SHIELD_PORT/repo|" "$PACMAN_CONF"
|
||||||
echo "✓ Updated repo server URL"
|
echo "✓ Updated repo server URL"
|
||||||
else
|
else
|
||||||
echo "Adding [aur-shield] to $PACMAN_CONF..."
|
echo "Adding [aur-shield] to $PACMAN_CONF..."
|
||||||
sudo tee -a "$PACMAN_CONF" > /dev/null << EOF
|
sudo tee -a "$PACMAN_CONF" > /dev/null << EOF
|
||||||
|
|
||||||
# AUR-Shield — AI-scanned AUR packages
|
# AUR-Shield — AI-scanned AUR packages
|
||||||
$REPO_ENTRY
|
$REPO_ENTRY
|
||||||
EOF
|
EOF
|
||||||
echo "✓ Added repo entry"
|
echo "✓ Added repo entry"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install safe-yay wrapper
|
# Install safe-yay wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user