peliprint/blueprint/lib/grabenv.sh

32 lines
1,023 B
Bash
Raw Normal View History

#!/bin/bash
#
# This script has been created as part of the Blueprint source code
# and may be intergrated directly into the core in the future.
#
# Commands:
# - grabAppUrl string
# - grabAppDebug bool
# - grabAppTimezone string
# - grabAppLocale string
cd "${BLUEPRINT__FOLDER}"
env_file=".env"
while IFS= read -r line; do
if [[ $line == \#* ]]; then
continue
fi
if [[ $line == *"="* ]]; then
variable_name=$(echo "$line" | cut -d= -f1)
variable_value=$(echo "$line" | cut -d= -f2-)
variable_name=$(echo "$variable_name" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
variable_value=$(echo "$variable_value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sed 's/^"\(.*\)"$/\1/')
declare "$variable_name=$variable_value"
fi
done < "$env_file"
grabAppUrl() { echo $APP_URL; }
grabAppDebug() { echo $APP_DEBUG; }
grabAppTimezone() { echo $APP_TIMEZONE; }
grabAppLocale() { echo $APP_LOCALE; }