From edfec17f18ae8a8e2aceccd94acae71af54254ce Mon Sep 17 00:00:00 2001 From: joglomedia Date: Sat, 31 Aug 2019 10:35:00 +0700 Subject: [PATCH] enhance dotenv --- .env.dist | 2 +- lemper.sh | 6 +----- scripts/helper.sh | 7 ++++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.env.dist b/.env.dist index e85bfca..4f25294 100644 --- a/.env.dist +++ b/.env.dist @@ -14,7 +14,7 @@ LEMPER_USERNAME="lemper" LEMPER_PASSWORD="" # Administration email. Don't leave it blank! -ADMIN_EMAIL="admin@lemper.sh" +ADMIN_EMAIL="support@lemper.sh" # Auto install, true for auto installation, # false for manual or guided installation. diff --git a/lemper.sh b/lemper.sh index 4abfbb6..1624dc8 100755 --- a/lemper.sh +++ b/lemper.sh @@ -32,15 +32,11 @@ # Work even if somebody does "sh lemper.sh". set -e +# Try to export global path. if [ -z "${PATH}" ] ; then export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin fi -# Unset existing variables. -# shellcheck source=.env -# shellcheck disable=SC2046 -unset $(grep -v '^#' .env | grep -v '^\[' | sed -E 's/(.*)=.*/\1/' | xargs) - # Get base directory. export BASEDIR && \ BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) diff --git a/scripts/helper.sh b/scripts/helper.sh index 4df4f77..73834c0 100644 --- a/scripts/helper.sh +++ b/scripts/helper.sh @@ -8,11 +8,16 @@ # Export environment variables. if [ -f ".env" ]; then + # Clean environemnt first. + # shellcheck source=.env + # shellcheck disable=SC2046 + unset $(grep -v '^#' .env | grep -v '^\[' | sed -E 's/(.*)=.*/\1/' | xargs) + # shellcheck source=.env # shellcheck disable=SC1094 source <(grep -v '^#' .env | grep -v '^\[' | sed -E 's|^(.+)=(.*)$|: ${\1=\2}; export \1|g') else - echo "Environment variables required, but not found." + echo "Environment variables required, but the Dotenv file not found." exit 1 fi