@@ -368,6 +368,51 @@ run_container_safe() {
368368 " || __handle_general_error "lxc-attach to CT $ct"
369369}
370370
371+ cleanup_lxc() {
372+ msg_info "Cleaning up"
373+ if is_alpine; then
374+ $STD apk cache clean || true
375+ rm -rf /var/cache/apk/*
376+ else
377+ $STD apt -y autoremove || true
378+ $STD apt -y autoclean || true
379+ $STD apt -y clean || true
380+ fi
381+
382+ rm -rf /tmp/* /var/tmp/*
383+
384+ # Remove temp files created by mktemp/tempfile
385+ find /tmp /var/tmp -type f -name 'tmp*' -delete 2>/dev/null || true
386+ find /tmp /var/tmp -type f -name 'tempfile*' -delete 2>/dev/null || true
387+
388+ find /var/log -type f -exec truncate -s 0 {} +
389+
390+ # Python pip
391+ if command -v pip &>/dev/null; then pip cache purge || true; fi
392+ # Python uv
393+ if command -v uv &>/dev/null; then uv cache clear || true; fi
394+ # Node.js npm
395+ if command -v npm &>/dev/null; then npm cache clean --force || true; fi
396+ # Node.js yarn
397+ if command -v yarn &>/dev/null; then yarn cache clean || true; fi
398+ # Node.js pnpm
399+ if command -v pnpm &>/dev/null; then pnpm store prune || true; fi
400+ # Go
401+ if command -v go &>/dev/null; then go clean -cache -modcache || true; fi
402+ # Rust cargo
403+ if command -v cargo &>/dev/null; then cargo clean || true; fi
404+ # Ruby gem
405+ if command -v gem &>/dev/null; then gem cleanup || true; fi
406+ # Composer (PHP)
407+ if command -v composer &>/dev/null; then composer clear-cache || true; fi
408+
409+ if command -v journalctl &>/dev/null; then
410+ $STD journalctl --rotate
411+ $STD journalctl --vacuum-time=10m
412+ fi
413+ msg_ok "Cleaned"
414+ }
415+
371416check_or_create_swap() {
372417 msg_info "Checking for active swap"
373418
0 commit comments