fix+refact(system-cleanup) (#856)

* fix(system-cleanup): some issues

* new packager quotes
This commit is contained in:
Adam Perkowski 2024-10-24 21:59:23 +02:00 committed by GitHub
parent 51631a16cb
commit e3688e9b3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

13
core/tabs/system-setup/system-cleanup.sh Normal file → Executable file
View File

@ -26,16 +26,21 @@ cleanup_system() {
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1 "$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
;; ;;
*) *)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}"
return 1
;; ;;
esac esac
} }
common_cleanup() { common_cleanup() {
if [ -d /var/tmp ]; then
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete "$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
fi
if [ -d /tmp ]; then
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete "$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 {} \; "$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
fi
"$ESCALATION_TOOL" journalctl --vacuum-time=3d "$ESCALATION_TOOL" journalctl --vacuum-time=3d
} }
@ -45,8 +50,12 @@ clean_data() {
case $clean_response in case $clean_response in
y|Y) y|Y)
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}" printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
if [ -d "$HOME/.cache" ]; then
find "$HOME/.cache/" -type f -atime +5 -delete find "$HOME/.cache/" -type f -atime +5 -delete
fi
if [ -d "$HOME/.local/share/Trash" ]; then
find "$HOME/.local/share/Trash" -mindepth 1 -delete find "$HOME/.local/share/Trash" -mindepth 1 -delete
fi
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}" printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
;; ;;
*) *)