From c88d8a09961d9a7918c7ee78a980f7516860d93e Mon Sep 17 00:00:00 2001 From: LoreleiAurora Date: Wed, 4 Jan 2017 17:48:56 +0000 Subject: [PATCH 1/5] Add hosts defined in config file to machine host file --- provision/provision-site.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index db96d62b1..b3a9be900 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -9,6 +9,11 @@ NGINX_UPSTREAM=$6 VVV_PATH_TO_SITE=${VM_DIR} VVV_SITE_NAME=${SITE} +VVV_CONFIG=/vagrant/vvv-config.yml +if [[ -f /vagrant/vvv-custom.yml ]]; then + VVV_CONFIG=/vagrant/vvv-custom.yml +fi + noroot() { sudo -EH -u "vagrant" "$@"; } @@ -90,6 +95,12 @@ if [[ -d ${VM_DIR} ]]; then fi done < "$hostfile" done -fi + for line in `cat ${VVV_CONFIG} | shyaml get-values sites.${SITE}.hosts`; do + if [[ -z "$(grep -q "^127.0.0.1 $line$" /etc/hosts)" ]]; then + echo "127.0.0.1 $line # vvv-auto" >> "/etc/hosts" + echo " * Added $line from ${VVV_CONFIG}" + fi + done +fi service nginx restart From 361d579c47bf33b8e11a4988b58f7654b22ca2de Mon Sep 17 00:00:00 2001 From: LoreleiAurora Date: Sat, 7 Jan 2017 03:00:38 +0000 Subject: [PATCH 2/5] escape period in site name for shyaml --- provision/provision-site.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index b3a9be900..84f213f8b 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash SITE=$1 +SITE_ESCAPED=`echo ${SITE} | sed 's/\./\\\\./g'` REPO=$2 BRANCH=$3 VM_DIR=$4 @@ -96,7 +97,7 @@ if [[ -d ${VM_DIR} ]]; then done < "$hostfile" done - for line in `cat ${VVV_CONFIG} | shyaml get-values sites.${SITE}.hosts`; do + for line in `cat ${VVV_CONFIG} | shyaml get-values sites.${SITE_ESCAPED}.hosts`; do if [[ -z "$(grep -q "^127.0.0.1 $line$" /etc/hosts)" ]]; then echo "127.0.0.1 $line # vvv-auto" >> "/etc/hosts" echo " * Added $line from ${VVV_CONFIG}" From f5dee3273d34f232f00b6307a521455299094ac7 Mon Sep 17 00:00:00 2001 From: LoreleiAurora Date: Tue, 17 Jan 2017 23:38:08 +0000 Subject: [PATCH 3/5] Update get_config_value to use gloval variable --- provision/provision-site.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 84f213f8b..f828ad4cf 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -22,11 +22,7 @@ noroot() { # Takes 2 values, a key to fetch a value for, and an optional default value # e.g. echo `get_config_value 'key' 'defaultvalue'` get_config_value() { - local config=/vagrant/vvv-config.yml - if [[ -f /vagrant/vvv-custom.yml ]]; then - config=/vagrant/vvv-custom.yml - fi - local value=`cat ${config} | shyaml get-value sites.${SITE}.custom.${1} 2> /dev/null` + local value=`cat ${VVV_CONFIG} | shyaml get-value sites.${SITE}.custom.${1} 2> /dev/null` echo ${value:-$2} } From 233b96b4d9bab979958e253d226897b96375083c Mon Sep 17 00:00:00 2001 From: LoreleiAurora Date: Tue, 17 Jan 2017 23:39:34 +0000 Subject: [PATCH 4/5] Update get_config_value to use escaped site name --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index f828ad4cf..0c36f8ebe 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -22,7 +22,7 @@ noroot() { # Takes 2 values, a key to fetch a value for, and an optional default value # e.g. echo `get_config_value 'key' 'defaultvalue'` get_config_value() { - local value=`cat ${VVV_CONFIG} | shyaml get-value sites.${SITE}.custom.${1} 2> /dev/null` + local value=`cat ${VVV_CONFIG} | shyaml get-value sites.${SITE_ESCAPED}.custom.${1} 2> /dev/null` echo ${value:-$2} } From 1fffdc6a0177cf169ba63424ad509d092ad2ed8b Mon Sep 17 00:00:00 2001 From: LoreleiAurora Date: Tue, 17 Jan 2017 23:47:01 +0000 Subject: [PATCH 5/5] Suppress shyaml errors when key does not exist --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 0c36f8ebe..78bbbed11 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -93,7 +93,7 @@ if [[ -d ${VM_DIR} ]]; then done < "$hostfile" done - for line in `cat ${VVV_CONFIG} | shyaml get-values sites.${SITE_ESCAPED}.hosts`; do + for line in `cat ${VVV_CONFIG} | shyaml get-values sites.${SITE_ESCAPED}.hosts 2> /dev/null`; do if [[ -z "$(grep -q "^127.0.0.1 $line$" /etc/hosts)" ]]; then echo "127.0.0.1 $line # vvv-auto" >> "/etc/hosts" echo " * Added $line from ${VVV_CONFIG}"