From 20a4364fd6f25b691007d753c70b8585abee5141 Mon Sep 17 00:00:00 2001 From: BeauTroll <-> Date: Thu, 18 Dec 2025 17:40:10 +0100 Subject: [PATCH] Improve error handling in test-notifications script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/test-notifications.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/test-notifications.sh b/scripts/test-notifications.sh index 3530ba2..1a45900 100755 --- a/scripts/test-notifications.sh +++ b/scripts/test-notifications.sh @@ -12,13 +12,18 @@ BLUE='\033[0;34m' NC='\033[0m' # Charger les variables d'environnement -if [ -f /etc/borgmatic/.env ]; then +if [ -r /etc/borgmatic/.env ]; then source /etc/borgmatic/.env -elif [ -f .env ]; then +elif [ -r .env ]; then source .env else - echo -e "${RED}❌ Fichier .env non trouvĂ©${NC}" - echo "CrĂ©ez un fichier .env avec NTFY_URL et NTFY_USER" + echo -e "${RED}❌ Fichier .env non trouvĂ© ou non lisible${NC}" + 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 fi