Skip to content

Commit 70dd8d7

Browse files
author
Mashruk Kabir
authored
cleanup (#478)
1 parent 6e477fc commit 70dd8d7

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh -e
2+
3+
. ../common-script.sh
4+
5+
cleanup_system() {
6+
printf "%b\n" "${YELLOW}Performing system cleanup...${RC}"
7+
case "$PACKAGER" in
8+
apt-get|nala)
9+
"$ESCALATION_TOOL" "$PACKAGER" clean
10+
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
11+
"$ESCALATION_TOOL" "$PACKAGER" autoclean
12+
"$ESCALATION_TOOL" du -h /var/cache/apt
13+
"$ESCALATION_TOOL" "$PACKAGER" clean
14+
;;
15+
zypper)
16+
"$ESCALATION_TOOL" "$PACKAGER" clean -a
17+
"$ESCALATION_TOOL" "$PACKAGER" tidy
18+
"$ESCALATION_TOOL" "$PACKAGER" cc -a
19+
;;
20+
dnf)
21+
"$ESCALATION_TOOL" "$PACKAGER" clean all
22+
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
23+
;;
24+
pacman)
25+
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
26+
"$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm
27+
;;
28+
*)
29+
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
30+
return 1
31+
;;
32+
esac
33+
}
34+
35+
common_cleanup() {
36+
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
37+
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete
38+
"$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
39+
"$ESCALATION_TOOL" journalctl --vacuum-time=3d
40+
}
41+
42+
clean_data() {
43+
printf "%b\n" "${YELLOW}Clean up old cache files and empty the trash? (y/N): ${RC}"
44+
read -r clean_response
45+
case $clean_response in
46+
y|Y)
47+
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
48+
find "$HOME/.cache/" -type f -atime +5 -delete
49+
find "$HOME/.local/share/Trash" -mindepth 1 -delete
50+
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
51+
;;
52+
*)
53+
printf "%b\n" "${YELLOW}Skipping cache and trash cleanup.${RC}"
54+
;;
55+
esac
56+
}
57+
58+
checkEnv
59+
checkEscalationTool
60+
cleanup_system
61+
common_cleanup
62+
clean_data

tabs/system-setup/tab_data.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ name = "RPM Fusion Setup"
3636
description = "RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship.\nThat software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit.\nFor more information visit: https://rpmfusion.org/"
3737
script = "fedora/rpm-fusion-setup.sh"
3838

39+
[[data]]
40+
name = "Full System Cleanup"
41+
script = "system-cleanup.sh"
42+
3943
[[data]]
4044
name = "Full System Update"
4145
description = "This command updates your system to the latest packages available for your distro"

0 commit comments

Comments
 (0)