mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-12-25 21:09:45 +00:00
cca2660c3b
* increase synergy between scripts * Fix newlines Fix packagers etc * fix an issue with no new line being created * fix formatting Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * fix extra comma Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * remove extra comma Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * remove "please" Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add support for caps Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add support for caps Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add support for caps Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * remove \n and make the default option "N" Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add an extra quote Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add extra quotes * fix remaining sn * fix remaining new lines --------- Co-authored-by: nnyyxxxx <nnyyxxxx@users.noreply.github.com> Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
63 lines
2.0 KiB
Bash
63 lines
2.0 KiB
Bash
#!/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
|