From 5ded2bc3200a7ce69905b617eb82a1c4900be890 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 23 Jul 2021 18:04:48 -0600 Subject: [PATCH] refactor(entrypoint): use lowercase boolean values - convert boolean environment vars to lowercase - allows single use between shell and JavaScript --- build/entrypoint.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/build/entrypoint.sh b/build/entrypoint.sh index 5ca934f..0ceeeef 100644 --- a/build/entrypoint.sh +++ b/build/entrypoint.sh @@ -5,13 +5,6 @@ # # functions -certificateCheckEnabled() { - if [ "$httpsEnabled" != "TRUE" ]; then - printf "\nSSL/TLS not enabled. Please set LR_HTTPS=TRUE if you want to enable SSL/TLS.\n" - exit 1 - fi -} - certificateCheckExist() { if [ -n "$(find /certs/ -type d -empty -print)" ]; then printf "noexist" @@ -41,13 +34,12 @@ certificateGenerateNew() { } certificateShow() { - certificateCheckEnabled printf "\nCurrently loaded certificate:\n" exit 0 } -convertCaseUpper() { - printf "%s" "$1" | tr "[:lower:]" "[:upper:]" +convertCaseLower() { + printf "%s" "$1" | tr "[:upper:]" "[:lower:]" } # default variable values @@ -55,7 +47,12 @@ doCertNew=0 doCertShow=0 doServer=0 doShell=0 -httpsEnabled="$(convertCaseUpper "$LR_HTTPS")" + +# clean-up boolean environment variables for this script and JavaScript +enableHTTPS="$(convertCaseLower "$LR_HTTPS")" +enableDebug="$(convertCaseLower "$LR_DEBUG")" +export LR_HTTPS="$enableHTTPS" +export LR_DEBUG="$enableDebug" # process action parameter case "$1" in @@ -84,7 +81,7 @@ if [ "$doServer" -eq 1 ]; then printf "Starting LiveReload server:\n" # https pre-flight check - if [ "$httpsEnabled" = "TRUE" ]; then + if [ "$enableHTTPS" = "true" ]; then printf "[SSL/TLS mode enabled]\n" certStatus="$(certificateCheckExist)" case "$certStatus" in