Skip to content

Commit

Permalink
add install.sh proxy support
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Wright <patrick@chef.io>
  • Loading branch information
Patrick Wright committed Sep 14, 2017
1 parent 03460f6 commit a2e58a6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ options = {
Mixlib::Install.new(options).install_command
```

#### Proxies
The API uses Ruby's OpenURI module to load proxy environment variables (`http_proxy`, `https_proxy`, `ftp_proxy`, `no_proxy`).

When `install.sh` and `install.ps1` are executed as standalone scripts the will rely on environment variables to configure proxy settings. The install scripts will not configure proxy settings by default.

In order to customize the proxy environment variables for generated install scripts they must be set by the `install_command_options` option. Setting these options will override session environment variables.

Bourne install script (`install.sh`) supports `http_proxy`, `https_proxy`, `ftp_proxy`, and `no_proxy` passed as keys to `install_command_options`.

Powershell install script (`install.ps1`) supports `http_proxy` passed as a key to `install_command_options`.

## Development
VCR is a tool that helps cache and replay http responses. When these responses change or when you add more tests you might need to update cached responses. Check out [spec_helper.rb](https://github.com/chef/mixlib-install/blob/master/spec/spec_helper.rb) for instructions on how to do this.
Expand Down
2 changes: 2 additions & 0 deletions lib/mixlib/install/generator/bourne.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def self.install_sh(context)
install_command << get_script("script_cli_parameters.sh")
install_command << get_script("check_product.sh")
install_command << get_script("platform_detection.sh")
install_command << get_script("proxy_env.sh")
install_command << get_script("fetch_metadata.sh", context)
install_command << get_script("fetch_package.sh")
install_command << get_script("install_package.sh")
Expand All @@ -47,6 +48,7 @@ def install_command
install_command << render_variables
install_command << get_script("check_product.sh")
install_command << get_script("platform_detection.sh")
install_command << get_script("proxy_env.sh")
install_command << get_script("fetch_metadata.sh")
install_command << get_script("fetch_package.sh")
install_command << get_script("install_package.sh")
Expand Down
28 changes: 28 additions & 0 deletions lib/mixlib/install/generator/bourne/scripts/proxy_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# All of the download utilities in this script load common proxy env vars.
# If variables are set they will override any existing env vars.
# Otherwise, default proxy env vars will be loaded by the respective
# download utility.

if test "x$https_proxy" != "x"; then
echo "setting https_proxy: $https_proxy"
export HTTPS_PROXY=$https_proxy
export https_proxy=$https_proxy
fi

if test "x$http_proxy" != "x"; then
echo "setting http_proxy: $http_proxy"
export HTTP_PROXY=$http_proxy
export http_proxy=$http_proxy
fi

if test "x$ftp_proxy" != "x"; then
echo "setting ftp_proxy: $ftp_proxy"
export FTP_PROXY=$ftp_proxy
export ftp_proxy=$ftp_proxy
fi

if test "x$no_proxy" != "x"; then
echo "setting no_proxy: $no_proxy"
export NO_PROXY=$no_proxy
export no_proxy=$no_proxy
fi

0 comments on commit a2e58a6

Please sign in to comment.