clean.sh 1.5 KB

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