commit 3f953ec88a3c9ebe9d6b741cb52e78760aa80322 Author: victor-alcalde Date: Fri May 30 17:29:15 2025 +0100 add: check storage script diff --git a/scripts/check_storage.sh b/scripts/check_storage.sh new file mode 100755 index 0000000..8fe354d --- /dev/null +++ b/scripts/check_storage.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -euo pipefail + +trap 'exit 1' INT + +#Colours +greenColour="\e[0;32m\033[1m" +endColour="\033[0m\e[0m" +redColour="\e[0;31m\033[1m" +blueColour="\e[0;34m\033[1m" +yellowColour="\e[0;33m\033[1m" +purpleColour="\e[0;35m\033[1m" +turquoiseColour="\e[0;36m\033[1m" +grayColour="\e[0;37m\033[1m" + +space=$(df / | awk 'NR==2 {print $5}' | tr -d '%') +notification="${redColour}[!] Espacio superior a 85%{endColour} Eliminar archivos YA!" + +if [ $space -ge 85 ]; then + echo -e "\n$notification" + exit 1 +elif [ $space -ge 70 ]; then + echo -e "\n${blueColour} Poco espacio \n tienes:${purpleColour}$(( 100 - $space))%${endColour}${blueColour} de espacio libre ${endColour}" + exit 1 +else + echo -e "\n ${greenColour}[+] Vas bien de espacio \n tienes $(( 100 - $space))% de espacio libre ${endColour}" +fi + +exit 0