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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user