clean.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. function header_info() {
  7. clear
  8. cat <<"EOF"
  9. ________ __ _ ________
  10. / ____/ /__ ____ _____ / / | |/ / ____/
  11. / / / / _ \/ __ `/ __ \ / / | / /
  12. / /___/ / __/ /_/ / / / / / /___/ / /___
  13. \____/_/\___/\__,_/_/ /_/ /_____/_/|_\____/
  14. EOF
  15. }
  16. BL=$(echo "\033[36m")
  17. GN=$(echo "\033[1;92m")
  18. CL=$(echo "\033[m")
  19. name=$(hostname)
  20. header_info
  21. echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n"
  22. cache=$(find /var/cache/ -type f)
  23. if [[ -z "$cache" ]]; then
  24. echo -e "It appears there are no cached files on your system. \n"
  25. sleep 2
  26. else
  27. echo -e "$cache \n"
  28. echo -e "${GN}Cache in $name${CL}"
  29. read -p "Would you like to remove the selected cache listed above? [y/N] " -n 1 -r
  30. echo
  31. if [[ $REPLY =~ ^[Yy]$ ]]; then
  32. echo "Removing cache"
  33. find /var/cache -type f -delete
  34. echo "Successfully Removed cache"
  35. sleep 2
  36. fi
  37. fi
  38. header_info
  39. echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n"
  40. logs=$(find /var/log/ -type f)
  41. if [[ -z "$logs" ]]; then
  42. echo -e "It appears there are no logs on your system. \n"
  43. sleep 2
  44. else
  45. echo -e "$logs \n"
  46. echo -e "${GN}Logs in $name${CL}"
  47. read -p "Would you like to remove the selected logs listed above? [y/N] " -n 1 -r
  48. echo
  49. if [[ $REPLY =~ ^[Yy]$ ]]; then
  50. echo "Removing logs"
  51. find /var/log -type f -delete
  52. echo "Successfully Removed logs"
  53. sleep 2
  54. fi
  55. fi
  56. header_info
  57. echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n"
  58. echo -e "${GN}Populating apt lists${CL} \n"