Files
proxmox/scripts/cleanup-blockscout-journal.sh.bak
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

96 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Clean up systemd journal logs in Blockscout container
# Usage: ./cleanup-blockscout-journal.sh [proxmox-host]
set -e
PROXMOX_HOST="${1:-192.168.11.12}"
VMID=5000
echo "=========================================="
echo "Cleanup Blockscout Journal Logs"
echo "=========================================="
echo "Proxmox Host: $PROXMOX_HOST"
echo "VMID: $VMID"
echo "=========================================="
echo ""
# Check container status
STATUS=$(ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct status $VMID 2>/dev/null | awk '{print \$2}'" || echo "unknown")
if [ "$STATUS" != "running" ]; then
echo "❌ Container is not running (status: $STATUS)"
exit 1
fi
# Get current journal size
echo "=== Current Journal Size ==="
CURRENT_SIZE=$(ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- journalctl --disk-usage 2>/dev/null | awk '{print \$1}'" || echo "unknown")
echo "Current journal size: $CURRENT_SIZE"
echo ""
# Get current disk usage
echo "=== Current Disk Usage ==="
ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- df -h / | tail -1" || echo "Unable to check disk usage"
echo ""
# Ask for cleanup method
CLEANUP_METHOD="${2:-size}"
JOURNAL_LIMIT="${3:-100M}"
echo "=== Cleanup Options ==="
echo "1. Clean up by size (keep last 100MB)"
echo "2. Clean up by time (keep last 3 days)"
echo ""
if [ "$CLEANUP_METHOD" = "time" ]; then
echo "Cleaning up journal logs (keeping last 3 days)..."
ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- journalctl --vacuum-time=3d"
elif [ "$CLEANUP_METHOD" = "size" ]; then
echo "Cleaning up journal logs (keeping last $JOURNAL_LIMIT)..."
ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- journalctl --vacuum-size=$JOURNAL_LIMIT"
else
echo "❌ Unknown cleanup method: $CLEANUP_METHOD"
exit 1
fi
echo ""
echo "=== Journal Size After Cleanup ==="
NEW_SIZE=$(ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- journalctl --disk-usage 2>/dev/null | awk '{print \$1}'" || echo "unknown")
echo "Journal size after cleanup: $NEW_SIZE"
echo ""
# Configure journal limits
echo "=== Configuring Journal Limits ==="
ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- bash << 'EOF'
if ! grep -q '^SystemMaxUse=' /etc/systemd/journald.conf; then
echo 'SystemMaxUse=$JOURNAL_LIMIT' >> /etc/systemd/journald.conf
echo '✅ Added SystemMaxUse=$JOURNAL_LIMIT to journald.conf'
else
sed -i 's/^SystemMaxUse=.*/SystemMaxUse=$JOURNAL_LIMIT/' /etc/systemd/journald.conf
echo '✅ Updated SystemMaxUse to $JOURNAL_LIMIT in journald.conf'
fi
# Restart journald
systemctl restart systemd-journald
echo '✅ Restarted systemd-journald'
EOF
" || echo "⚠️ Unable to configure journal limits"
echo ""
echo "=== Disk Usage After Cleanup ==="
ssh -o StrictHostKeyChecking=no root@$PROXMOX_HOST "pct exec $VMID -- df -h / | tail -1" || echo "Unable to check disk usage"
echo ""
echo "=========================================="
echo "Cleanup Complete"
echo "=========================================="
echo ""
echo "Summary:"
echo " Before: $CURRENT_SIZE"
echo " After: $NEW_SIZE"
echo ""
echo "To verify cleanup:"
echo " ssh root@$PROXMOX_HOST 'pct exec $VMID -- journalctl --disk-usage'"
echo ""