From e3688e9b3d2f3594bf2367af87a800db9e2f1bbd Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Thu, 24 Oct 2024 21:59:23 +0200 Subject: [PATCH] fix+refact(system-cleanup) (#856) * fix(system-cleanup): some issues * new packager quotes --- core/tabs/system-setup/system-cleanup.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) mode change 100644 => 100755 core/tabs/system-setup/system-cleanup.sh diff --git a/core/tabs/system-setup/system-cleanup.sh b/core/tabs/system-setup/system-cleanup.sh old mode 100644 new mode 100755 index 0a625913..2641a14f --- a/core/tabs/system-setup/system-cleanup.sh +++ b/core/tabs/system-setup/system-cleanup.sh @@ -26,16 +26,21 @@ cleanup_system() { "$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1 ;; *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - return 1 + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}" ;; esac } common_cleanup() { - "$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete - "$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete - "$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \; + if [ -d /var/tmp ]; then + "$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete + fi + if [ -d /tmp ]; then + "$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete + fi + if [ -d /var/log ]; then + "$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \; + fi "$ESCALATION_TOOL" journalctl --vacuum-time=3d } @@ -45,8 +50,12 @@ clean_data() { case $clean_response in y|Y) printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}" - find "$HOME/.cache/" -type f -atime +5 -delete - find "$HOME/.local/share/Trash" -mindepth 1 -delete + if [ -d "$HOME/.cache" ]; then + find "$HOME/.cache/" -type f -atime +5 -delete + fi + if [ -d "$HOME/.local/share/Trash" ]; then + find "$HOME/.local/share/Trash" -mindepth 1 -delete + fi printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}" ;; *)