From b376b85d3718ba16c86398b753e03f69a3b80535 Mon Sep 17 00:00:00 2001 From: Dharmin K Shah <6830654+dharmin@users.noreply.github.com> Date: Mon, 12 Feb 2018 12:27:30 +0530 Subject: [PATCH 1/5] Added 'ee4 list' command --- scripts/ee4 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/ee4 b/scripts/ee4 index e931c1a..e2f546d 100755 --- a/scripts/ee4 +++ b/scripts/ee4 @@ -28,7 +28,8 @@ help () { echo -e "\nCommands: " echo -e "\tcreate\t\t\tCreate new site" - echo -e "\tdb\t\t\tEnter mysql shell" + echo -e "\tlist\t\t\tShow the list of created sites" + echo -e "\tdb\t\t\tEnter mysql shell" echo -e "\tdelete\t\t\tDelete existing site" echo -e "\trestart\t\t\tReload configuration for existing site" echo -e "\twp\t\t\tUse wp-cli with a site" @@ -59,6 +60,17 @@ createWebroot() fi } +# show the list of sites +listSites() { + SITE_LIST=$(ls -l $WEBROOT 2> /dev/null | awk '/^d/ {print $9}') + if [[ ${#SITE_LIST} -eq 0 ]]; then + echo -e "\e[1;31mNo sites have been created." + else + echo -e "\n\e[1;32mList of Sites:\n\n\e[1;38;5;25m$SITE_LIST" + fi +} + + singleWordPress() { createWebroot @@ -366,6 +378,9 @@ while [[ $# -gt 0 ]]; do exit 0 fi ;; + 'list') + listSites + ;; 'delete') shift if [[ $# -ne 0 ]]; then From 84e5a7af0a7077e0802a90d85a8aaf9cff836b7d Mon Sep 17 00:00:00 2001 From: Dharmin K Shah <6830654+dharmin@users.noreply.github.com> Date: Tue, 13 Feb 2018 13:12:43 +0530 Subject: [PATCH 2/5] Removed colors from 'ee list' command --- scripts/ee4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ee4 b/scripts/ee4 index e2f546d..57f8a3a 100755 --- a/scripts/ee4 +++ b/scripts/ee4 @@ -64,9 +64,9 @@ createWebroot() listSites() { SITE_LIST=$(ls -l $WEBROOT 2> /dev/null | awk '/^d/ {print $9}') if [[ ${#SITE_LIST} -eq 0 ]]; then - echo -e "\e[1;31mNo sites have been created." + echo -e "No sites have been created." else - echo -e "\n\e[1;32mList of Sites:\n\n\e[1;38;5;25m$SITE_LIST" + echo -e "List of Sites:\n\n$SITE_LIST" fi } From 70079d8fa3c78a8fb9765669e488ca2896b7f85f Mon Sep 17 00:00:00 2001 From: Dharmin K Shah <6830654+dharmin@users.noreply.github.com> Date: Wed, 14 Feb 2018 12:02:30 +0530 Subject: [PATCH 3/5] Fixed list command to show only valid sites. --- scripts/ee4 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/ee4 b/scripts/ee4 index 57f8a3a..b2233d6 100755 --- a/scripts/ee4 +++ b/scripts/ee4 @@ -61,14 +61,22 @@ createWebroot() } # show the list of sites -listSites() { - SITE_LIST=$(ls -l $WEBROOT 2> /dev/null | awk '/^d/ {print $9}') - if [[ ${#SITE_LIST} -eq 0 ]]; then - echo -e "No sites have been created." - else - echo -e "List of Sites:\n\n$SITE_LIST" - fi -} + listSites() { + pushd $WEBROOT > /dev/null 2>&1 + SITE_LIST=$(find . -mindepth 2 -maxdepth 2 -name docker-compose.yml) + popd > /dev/null 2>&1 + pwd + if [[ ${#SITE_LIST} -eq 0 ]]; then + echo -e "No sites have been created." + else + echo -e "List of Sites:\n" + for SITE_DIR in $SITE_LIST;do + SITE=$(dirname $SITE_DIR | tr -d "./") + echo $SITE + done + fi + } + singleWordPress() { From 04d2249cb1cb5fe8023f68f1503e1c95491f9050 Mon Sep 17 00:00:00 2001 From: Dharmin K Shah <6830654+dharmin@users.noreply.github.com> Date: Wed, 14 Feb 2018 18:15:18 +0530 Subject: [PATCH 4/5] Removed unnecessery loop in list command --- scripts/ee4 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/ee4 b/scripts/ee4 index b2233d6..bdfdff2 100755 --- a/scripts/ee4 +++ b/scripts/ee4 @@ -63,17 +63,12 @@ createWebroot() # show the list of sites listSites() { pushd $WEBROOT > /dev/null 2>&1 - SITE_LIST=$(find . -mindepth 2 -maxdepth 2 -name docker-compose.yml) + SITE_LIST=$(find . -mindepth 2 -maxdepth 2 -name docker-compose.yml | xargs -I{} dirname {} | tr -d "./") popd > /dev/null 2>&1 - pwd if [[ ${#SITE_LIST} -eq 0 ]]; then echo -e "No sites have been created." else - echo -e "List of Sites:\n" - for SITE_DIR in $SITE_LIST;do - SITE=$(dirname $SITE_DIR | tr -d "./") - echo $SITE - done + echo -e "List of Sites:\n\n$SITE_LIST" fi } From bb39bfcd1a7f9b4becde724746a9e2d8442c3867 Mon Sep 17 00:00:00 2001 From: Dharmin K Shah <6830654+dharmin@users.noreply.github.com> Date: Thu, 15 Feb 2018 11:54:41 +0530 Subject: [PATCH 5/5] Fixed problem with tr to cut in 'ee4 list' command changed tr command to cut --- scripts/ee4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ee4 b/scripts/ee4 index bdfdff2..6fc400b 100755 --- a/scripts/ee4 +++ b/scripts/ee4 @@ -63,7 +63,7 @@ createWebroot() # show the list of sites listSites() { pushd $WEBROOT > /dev/null 2>&1 - SITE_LIST=$(find . -mindepth 2 -maxdepth 2 -name docker-compose.yml | xargs -I{} dirname {} | tr -d "./") + SITE_LIST=$(find . -mindepth 2 -maxdepth 2 -name docker-compose.yml | xargs -I{} dirname {} | cut -c3-) popd > /dev/null 2>&1 if [[ ${#SITE_LIST} -eq 0 ]]; then echo -e "No sites have been created."