From 758b1c092883e03b16ab9b924f38d9904005e058 Mon Sep 17 00:00:00 2001 From: Aric Renzo Date: Mon, 19 Jun 2017 15:43:53 -0400 Subject: [PATCH] Adding support for Environment variables with sudo -E --- README.md | 11 +++++++---- genesis.sh | 10 +++++----- join.sh | 10 +++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e1b505a8..7804473a 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,13 @@ docker build -t quay.io/attcomdev/promenade:experimental . ## Using Promenade Behind a Proxy -Modify the `genesis.sh` and `proxy.sh` scripts, passing in the URL and ports of the proxy server relative to the cluster hosts: +To use Promenade from behind a proxy, simply export `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variables on the vagrant host prior to executing the `genesis.sh` and `join.sh` scripts respectively. Alternatively, you may also export the `DOCKER_HTTP_PROXY`, `DOCKER_HTTPS_PROXY`, and `DOCKER_NO_PROXY` directly. Ensure you are running the script with `sudo -E` option to preserve the environment variables. ```bash -DOCKER_HTTP_PROXY="http://proxy.server.com:8080" -DOCKER_HTTPS_PROXY="https://proxy.server.com:8080" -DOCKER_NO_PROXY="localhost,127.0.0.1" +vagrant ssh n0 +cd /vagrant +export DOCKER_HTTP_PROXY="http://proxy.server.com:8080" +export DOCKER_HTTPS_PROXY="https://proxy.server.com:8080" +export DOCKER_NO_PROXY="localhost,127.0.0.1" +sudo -E /vagrant/genesis.sh /vagrant/example/vagrant-config.yaml ``` diff --git a/genesis.sh b/genesis.sh index 4e0d3676..2274f7e1 100755 --- a/genesis.sh +++ b/genesis.sh @@ -12,10 +12,10 @@ set -ex DOCKER_PACKAGE="docker.io" DOCKER_VERSION=1.12.6-0ubuntu1~16.04.1 -#Proxy Variables - set only if deploying behind a proxy -DOCKER_HTTP_PROXY="" -DOCKER_HTTPS_PROXY="" -DOCKER_NO_PROXY="" +#Proxy Variables +DOCKER_HTTP_PROXY=${DOCKER_HTTP_PROXY:-${HTTP_PROXY:-${http_proxy}}} +DOCKER_HTTPS_PROXY=${DOCKER_HTTPS_PROXY:-${HTTPS_PROXY:-${https_proxy}}} +DOCKER_NO_PROXY=${DOCKER_NO_PROXY:-${NO_PROXY:-${no_proxy}}} mkdir -p /etc/docker @@ -32,7 +32,7 @@ mkdir -p /etc/systemd/system/docker.service.d #Set HTTPS Proxy Variable cat < /etc/systemd/system/docker.service.d/http-proxy.conf [Service] -Environment="HTTP_PROXY=${DOCKER_HTTPS_PROXY}" +Environment="HTTP_PROXY=${DOCKER_HTTP_PROXY}" EOF #Set HTTPS Proxy Variable diff --git a/join.sh b/join.sh index d0ea0d3b..9ccb074b 100755 --- a/join.sh +++ b/join.sh @@ -12,10 +12,10 @@ set -ex DOCKER_PACKAGE="docker.io" DOCKER_VERSION=1.12.6-0ubuntu1~16.04.1 -#Proxy Variables - set only if deploying behind a proxy -DOCKER_HTTP_PROXY="" -DOCKER_HTTPS_PROXY="" -DOCKER_NO_PROXY="" +#Proxy Variables +DOCKER_HTTP_PROXY=${DOCKER_HTTP_PROXY:-${HTTP_PROXY:-${http_proxy}}} +DOCKER_HTTPS_PROXY=${DOCKER_HTTPS_PROXY:-${HTTPS_PROXY:-${https_proxy}}} +DOCKER_NO_PROXY=${DOCKER_NO_PROXY:-${NO_PROXY:-${no_proxy}}} mkdir -p /etc/docker @@ -32,7 +32,7 @@ mkdir -p /etc/systemd/system/docker.service.d #Set HTTPS Proxy Variable cat < /etc/systemd/system/docker.service.d/http-proxy.conf [Service] -Environment="HTTP_PROXY=${DOCKER_HTTPS_PROXY}" +Environment="HTTP_PROXY=${DOCKER_HTTP_PROXY}" EOF #Set HTTPS Proxy Variable