Improve error handling in test-notifications script

Fix permission error handling by checking file readability instead of
just existence, and provide clearer error messages with solutions.

Changes:
- Use -r flag instead of -f to check if .env is readable
- Add helpful error message with multiple solutions
- Guide users to either use sudo or create local .env file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
BeauTroll
2025-12-18 17:40:10 +01:00
parent ef82bca68e
commit 20a4364fd6

View File

@@ -12,13 +12,18 @@ BLUE='\033[0;34m'
NC='\033[0m' NC='\033[0m'
# Charger les variables d'environnement # Charger les variables d'environnement
if [ -f /etc/borgmatic/.env ]; then if [ -r /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env source /etc/borgmatic/.env
elif [ -f .env ]; then elif [ -r .env ]; then
source .env source .env
else else
echo -e "${RED}❌ Fichier .env non trouvé${NC}" echo -e "${RED}❌ Fichier .env non trouvé ou non lisible${NC}"
echo "Créez un fichier .env avec NTFY_URL et NTFY_USER" echo ""
echo "Solutions:"
echo " 1. Exécutez ce script avec sudo"
echo " 2. Créez un fichier .env local dans le dossier du projet"
echo " cp .env.example .env && nano .env"
echo ""
exit 1 exit 1
fi fi