From 4c688b2bc69651ba699fb4037adb089e8c895880 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Wed, 17 May 2023 15:48:00 -0700 Subject: [PATCH] rework macro verification --- bin/vhost-enable.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/vhost-enable.sh b/bin/vhost-enable.sh index d4a0966..3efe1a1 100755 --- a/bin/vhost-enable.sh +++ b/bin/vhost-enable.sh @@ -50,15 +50,8 @@ if [[ ! -n $domain ]]; then exit fi -# check for macro -if [[ -n $macro ]]; then - if [[ " ${macro_array[@]} " =~ " ${macro} " ]]; then - macro_vhost_line="Use $macro" - else - echo "invalid macro name" - exit 1 - fi -else +# autodetect macro to use if not set +if [[ ! -n $macro ]]; then if [[ "$domain" =~ ^mail.* ]]; then macro=VMailHTTPS elif [[ -f "/etc/ssl/letsencrypt/$domain.pem" ]]; then @@ -67,6 +60,13 @@ else macro=VHostHTTP fi fi +# verify macro name +if [[ " ${macro_array[@]} " =~ " ${macro} " ]]; then + macro_vhost_line="Use $macro" +else + echo "invalid macro name" + exit 1 +fi # if https check for le cert if [[ "$macro" == *"HTTPS"* ]]; then