@@ -368,6 +368,54 @@ run_container_safe() {
368368 " || __handle_general_error "lxc-attach to CT $ct"
369369}
370370
371+ cleanup_lxc() {
372+ msg_info "Cleaning up"
373+
374+ if is_alpine; then
375+ $STD apk cache clean || true
376+ rm -rf /var/cache/apk/*
377+ else
378+ $STD apt -y autoremove || true
379+ $STD apt -y autoclean || true
380+ $STD apt -y clean || true
381+ fi
382+
383+ # Clear temp artifacts (keep sockets/FIFOs; ignore errors)
384+ find /tmp /var/tmp -type f -name 'tmp*' -delete 2>/dev/null || true
385+ find /tmp /var/tmp -type f -name 'tempfile*' -delete 2>/dev/null || true
386+
387+ # Truncate writable log files silently (permission errors ignored)
388+ if command -v truncate >/dev/null 2>&1; then
389+ find /var/log -type f -writable -print0 2>/dev/null |
390+ xargs -0 -n1 truncate -s 0 2>/dev/null || true
391+ fi
392+
393+ # Python pip
394+ if command -v pip &>/dev/null; then $STD pip cache purge || true; fi
395+ # Python uv
396+ if command -v uv &>/dev/null; then $STD uv cache clear || true; fi
397+ # Node.js npm
398+ if command -v npm &>/dev/null; then $STD npm cache clean --force || true; fi
399+ # Node.js yarn
400+ if command -v yarn &>/dev/null; then $STD yarn cache clean || true; fi
401+ # Node.js pnpm
402+ if command -v pnpm &>/dev/null; then $STD pnpm store prune || true; fi
403+ # Go
404+ if command -v go &>/dev/null; then $STD go clean -cache -modcache || true; fi
405+ # Rust cargo
406+ if command -v cargo &>/dev/null; then $STD cargo clean || true; fi
407+ # Ruby gem
408+ if command -v gem &>/dev/null; then $STD gem cleanup || true; fi
409+ # Composer (PHP)
410+ if command -v composer &>/dev/null; then $STD composer clear-cache || true; fi
411+
412+ if command -v journalctl &>/dev/null; then
413+ $STD journalctl --rotate || true
414+ $STD journalctl --vacuum-time=10m || true
415+ fi
416+ msg_ok "Cleaned"
417+ }
418+
371419check_or_create_swap() {
372420 msg_info "Checking for active swap"
373421
@@ -407,6 +455,3 @@ check_or_create_swap() {
407455}
408456
409457trap 'stop_spinner' EXIT INT TERM
410-
411- # Initialize functions when core.func is sourced
412- load_functions
0 commit comments