refactor(entrypoint): use lowercase boolean values

- convert boolean environment vars to lowercase
- allows single use between shell and JavaScript
This commit is contained in:
Asif Bacchus 2021-07-23 18:04:48 -06:00
parent a184866de3
commit 5ded2bc320
1 changed files with 9 additions and 12 deletions

View File

@ -5,13 +5,6 @@
# #
# functions # 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() { certificateCheckExist() {
if [ -n "$(find /certs/ -type d -empty -print)" ]; then if [ -n "$(find /certs/ -type d -empty -print)" ]; then
printf "noexist" printf "noexist"
@ -41,13 +34,12 @@ certificateGenerateNew() {
} }
certificateShow() { certificateShow() {
certificateCheckEnabled
printf "\nCurrently loaded certificate:\n" printf "\nCurrently loaded certificate:\n"
exit 0 exit 0
} }
convertCaseUpper() { convertCaseLower() {
printf "%s" "$1" | tr "[:lower:]" "[:upper:]" printf "%s" "$1" | tr "[:upper:]" "[:lower:]"
} }
# default variable values # default variable values
@ -55,7 +47,12 @@ doCertNew=0
doCertShow=0 doCertShow=0
doServer=0 doServer=0
doShell=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 # process action parameter
case "$1" in case "$1" in
@ -84,7 +81,7 @@ if [ "$doServer" -eq 1 ]; then
printf "Starting LiveReload server:\n" printf "Starting LiveReload server:\n"
# https pre-flight check # https pre-flight check
if [ "$httpsEnabled" = "TRUE" ]; then if [ "$enableHTTPS" = "true" ]; then
printf "[SSL/TLS mode enabled]\n" printf "[SSL/TLS mode enabled]\n"
certStatus="$(certificateCheckExist)" certStatus="$(certificateCheckExist)"
case "$certStatus" in case "$certStatus" in