Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System Cleanup #478

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions tabs/system-setup/system-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh -e

. ../common-script.sh

cleanup_system() {
printf "%b\n" "${YELLOW}Performing system cleanup...${RC}"
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" clean
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
"$ESCALATION_TOOL" "$PACKAGER" autoclean
"$ESCALATION_TOOL" du -h /var/cache/apt
"$ESCALATION_TOOL" "$PACKAGER" clean
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" clean -a
"$ESCALATION_TOOL" "$PACKAGER" tidy
"$ESCALATION_TOOL" "$PACKAGER" cc -a
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" clean all
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
return 1
;;
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 {} \;
"$ESCALATION_TOOL" journalctl --vacuum-time=3d
}

clean_data() {
printf "%b\n" "${YELLOW}Clean up old cache files and empty the trash? (y/N): ${RC}"
read -r clean_response
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
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
;;
*)
printf "%b\n" "${YELLOW}Skipping cache and trash cleanup.${RC}"
;;
esac
}

checkEnv
checkEscalationTool
cleanup_system
common_cleanup
clean_data
4 changes: 4 additions & 0 deletions tabs/system-setup/tab_data.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ values = ["dnf"]
name = "RPM Fusion Setup"
script = "fedora/rpm-fusion-setup.sh"

[[data]]
name = "Full System Cleanup"
script = "system-cleanup.sh"

[[data]]
name = "Full System Update"
script = "system-update.sh"
Expand Down
Loading