Fix .env file parsing errors with better validation and error handling
This commit is contained in:
16
start.sh
16
start.sh
@@ -102,9 +102,19 @@ fi
|
||||
# Load custom environment variables if they exist
|
||||
if [ -f "/app/data/.env" ]; then
|
||||
echo "=> Loading custom environment variables from /app/data/.env"
|
||||
set -a # automatically export all variables
|
||||
source /app/data/.env
|
||||
set +a # stop automatically exporting
|
||||
# Validate .env file format before sourcing
|
||||
if grep -q "^[[:space:]]*[^#][^=]*=" /app/data/.env 2>/dev/null; then
|
||||
set -a # automatically export all variables
|
||||
if source /app/data/.env 2>/dev/null; then
|
||||
echo "=> Custom .env file loaded successfully"
|
||||
else
|
||||
echo "=> Warning: Error loading .env file, using Cloudron defaults"
|
||||
echo "=> Check /app/data/.env for syntax errors (values with spaces need quotes)"
|
||||
fi
|
||||
set +a # stop automatically exporting
|
||||
else
|
||||
echo "=> Warning: /app/data/.env appears to be empty or invalid, using Cloudron defaults"
|
||||
fi
|
||||
else
|
||||
echo "=> No custom .env file found, using Cloudron defaults"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user