enhance dotenv

This commit is contained in:
joglomedia
2019-08-31 10:35:00 +07:00
parent ba2c574a3b
commit edfec17f18
3 changed files with 8 additions and 7 deletions

View File

@@ -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.

View File

@@ -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 )

View File

@@ -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