From 1b7761ce8d844531cd9bb4857a576d5b18d71fc5 Mon Sep 17 00:00:00 2001 From: Hugo Peixoto Date: Sun, 19 Jul 2020 16:29:11 +0100 Subject: [PATCH 1/2] Refactor domain add functions --- plugins/domains/functions | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/domains/functions b/plugins/domains/functions index b5d7096c1..6a4974ab6 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -57,10 +57,7 @@ domains_add() { done for DOMAIN in "$@"; do - if [[ $( - grep -w -E "^$DOMAIN$" "$APP_VHOST_PATH" >/dev/null 2>&1 - echo $? - ) -eq 0 ]]; then + if grep -x --line-regexp --fixed-strings "$DOMAIN" "$APP_VHOST_PATH" 2> /dev/null; then dokku_log_info1 "Skipping: $DOMAIN already added to $APP" else echo "$DOMAIN" >>"$APP_VHOST_PATH" @@ -159,13 +156,10 @@ domains_add_global() { done for DOMAIN in "$@"; do - if [[ $( - grep -w -E "^$DOMAIN$" "$GLOBAL_VHOST_PATH" >/dev/null 2>&1 - echo $? - ) -eq 0 ]]; then - dokku_log_info1 "Skipping: $DOMAIN already added" + if grep -q --line-regexp --fixed-strings "$DOMAIN" "$GLOBAL_VHOST_PATH" 2> /dev/null; then + dokku_log_info1 "Skipping $DOMAIN: already added" else - grep -qxF "$DOMAIN" "$GLOBAL_VHOST_PATH" || echo "$DOMAIN" >>"$GLOBAL_VHOST_PATH" + echo "$DOMAIN" >>"$GLOBAL_VHOST_PATH" dokku_log_info1 "Added $DOMAIN" fi done From d5b2d0d98e87448719a8658a78b78fb520bbc5b3 Mon Sep 17 00:00:00 2001 From: Hugo Peixoto Date: Sun, 19 Jul 2020 16:29:35 +0100 Subject: [PATCH 2/2] Stop using VHOST when listing app domains and urls --- plugins/common/functions | 2 +- plugins/domains/functions | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index d377888b1..b1705fdfb 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -919,7 +919,7 @@ internal_get_app_urls() { echo "http://$(<"$DOKKU_ROOT/HOSTNAME"):$p" done else - echo "$SCHEME://$(<"$DOKKU_ROOT/VHOST")" + echo "$SCHEME://$(<"$DOKKU_ROOT/HOSTNAME")" fi fi } diff --git a/plugins/domains/functions b/plugins/domains/functions index 6a4974ab6..5baed3aec 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -215,14 +215,11 @@ get_app_domains() { verify_app_name "$1" local APP=$1 local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" - local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST" local GLOBAL_HOSTNAME_PATH="$DOKKU_ROOT/HOSTNAME" if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]]; then if [[ -f "$APP_VHOST_PATH" ]]; then cat "$APP_VHOST_PATH" - elif [[ -f "$GLOBAL_VHOST_PATH" ]]; then - cat "$GLOBAL_VHOST_PATH" elif [[ -f "$GLOBAL_HOSTNAME_PATH" ]]; then cat "$GLOBAL_HOSTNAME_PATH" fi