Proxmox/misc/clean.sh

58 lines
1.5 KiB
Bash
Raw Normal View History

2023-01-28 21:17:46 +00:00
#!/usr/bin/env bash
2023-01-29 20:20:01 +00:00
function header_info() {
2023-01-28 21:17:46 +00:00
cat <<"EOF"
________ __ _ ________
/ ____/ /__ ____ _____ / / | |/ / ____/
/ / / / _ \/ __ `/ __ \ / / | / /
/ /___/ / __/ /_/ / / / / / /___/ / /___
\____/_/\___/\__,_/_/ /_/ /_____/_/|_\____/
EOF
}
BL=$(echo "\033[36m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
name=$(hostname)
clear
header_info
2023-01-29 16:01:07 +00:00
echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n"
2023-01-28 21:17:46 +00:00
cache=$(find /var/cache/ -type f)
2023-01-29 20:20:01 +00:00
if [[ -z "$cache" ]]; then
echo -e "It appears there are no cached files on your system. \n"
sleep 2
else
echo -e "$cache \n"
echo -e "${GN}Cache in $name${CL}"
read -p "Would you like to remove the selected cache listed above? [y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Removing cache"
find /var/cache -type f -delete
echo "Successfully Removed cache"
2023-01-28 21:17:46 +00:00
sleep 2
2023-01-29 20:20:01 +00:00
fi
fi
2023-01-28 21:17:46 +00:00
clear
header_info
2023-01-29 16:01:07 +00:00
echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n"
2023-01-28 21:17:46 +00:00
logs=$(find /var/log/ -type f)
2023-01-29 20:20:01 +00:00
if [[ -z "$logs" ]]; then
echo -e "It appears there are no logs on your system. \n"
sleep 2
else
echo -e "$logs \n"
echo -e "${GN}Logs in $name${CL}"
2023-01-29 20:38:57 +00:00
read -p "Would you like to remove the selected logs listed above? [y/n] " -n 1 -r
2023-01-29 20:20:01 +00:00
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Removing logs"
find /var/log -type f -delete
echo "Successfully Removed logs"
2023-01-28 21:17:46 +00:00
sleep 2
2023-01-29 20:20:01 +00:00
fi
fi
clear
header_info
echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n"
echo -e "${GN}Populating apt lists${CL} \n"