Files
zroc/zroc-ova/scripts/05-cleanup.sh
T
Justin 0500ac171c feat: initial zROC project recreation (stubs for large files pending)
- 61 files across zroc-ui/ and zroc-ova/ directories
- Full content written for: config, auth, API layers, CSS, build files,
  OVA scripts, backend routes, charts, hooks, constants
- Stubs in place for: page components, Sidebar, TopBar, docker-compose,
  authentik client, blueprint YAML, packer HCL, workflows, setup wizard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 16:20:05 -04:00

40 lines
1.0 KiB
Bash

#!/usr/bin/env bash
# zroc-ova/scripts/05-cleanup.sh
set -euo pipefail
echo "==> [05-cleanup] Cleaning build artefacts"
rm -f /etc/sudoers.d/zroc-packer
apt-get autoremove -y
apt-get autoclean -y
apt-get clean
rm -rf /var/lib/apt/lists/*
journalctl --rotate
journalctl --vacuum-time=1s
find /var/log -type f -name "*.log" -delete
find /var/log -type f -name "*.gz" -delete
truncate -s 0 /var/log/wtmp /var/log/btmp /var/log/lastlog 2>/dev/null || true
unset HISTFILE
rm -f /home/zroc/.bash_history /root/.bash_history
history -c
cloud-init clean --logs 2>/dev/null || true
rm -rf /tmp/* /var/tmp/*
echo "==> [05-cleanup] Zeroing free space (this takes a moment)…"
dd if=/dev/zero of=/ZERO bs=4M status=progress 2>/dev/null || true
rm -f /ZERO
sync
SWAP_DEV=$(swapon --show=NAME --noheadings 2>/dev/null | head -1)
if [[ -n "$SWAP_DEV" ]]; then
swapoff "$SWAP_DEV"
dd if=/dev/zero of="$SWAP_DEV" bs=4M status=progress 2>/dev/null || true
mkswap "$SWAP_DEV"
fi
echo "==> [05-cleanup] Done — image ready for OVA packaging"