Skip to content

Commit 4692c84

Browse files
Merge pull request #314 from community-scripts/MickLesk-patch-1
core.func: push changes from upstream
2 parents 815024f + f092de2 commit 4692c84

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

scripts/core/core.func

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
371419
check_or_create_swap() {
372420
msg_info "Checking for active swap"
373421

@@ -409,4 +457,4 @@ check_or_create_swap() {
409457
trap 'stop_spinner' EXIT INT TERM
410458

411459
# Initialize functions when core.func is sourced
412-
load_functions
460+
load_functions

0 commit comments

Comments
 (0)