#!/bin/bash

<% if_p('env.http_proxy') do |http_proxy| %>
export HTTP_PROXY=<%= http_proxy %>
export http_proxy=<%= http_proxy %>
<% end %>

<% if_p('env.https_proxy') do |https_proxy| %>
export HTTPS_PROXY=<%= https_proxy %>
export https_proxy=<%= https_proxy %>
<% end %>

<% if_p('env.no_proxy') do |no_proxy| %>
export NO_PROXY=<%= no_proxy %>
export no_proxy=<%= no_proxy %>
<% end %>

read INPUT

BOSH_PACKAGES_DIR=${BOSH_PACKAGES_DIR:-/var/vcap/packages}
BOSH_JOBS_DIR=${BOSH_JOBS_DIR:-/var/vcap/jobs}

export PATH=$BOSH_PACKAGES_DIR/ruby_vcloud_cpi/bin:$BOSH_PACKAGES_DIR/bosh_vcloud_cpi_mkisofs/bin:$PATH

export BUNDLE_GEMFILE=$BOSH_PACKAGES_DIR/bosh_vcloud_cpi/Gemfile

bundle_cmd="$BOSH_PACKAGES_DIR/ruby_vcloud_cpi/bin/bundle"

echo $INPUT | $bundle_cmd exec $BOSH_PACKAGES_DIR/bosh_vcloud_cpi/bin/vcloud_cpi \
$BOSH_JOBS_DIR/vcloud_cpi/config/cpi.json

exit 0

#!/bin/bash

<% if_p('env.http_proxy') do |http_proxy| %>
export HTTP_PROXY=<%= http_proxy %>
export http_proxy=<%= http_proxy %>
<% end %>

<% if_p('env.https_proxy') do |https_proxy| %>
export HTTPS_PROXY=<%= https_proxy %>
export https_proxy=<%= https_proxy %>
<% end %>

<% if_p('env.no_proxy') do |no_proxy| %>
export NO_PROXY=<%= no_proxy %>
export no_proxy=<%= no_proxy %>
<% end %>

read INPUT

BOSH_PACKAGES_DIR=${BOSH_PACKAGES_DIR:-/var/vcap/packages}
BOSH_JOBS_DIR=${BOSH_JOBS_DIR:-/var/vcap/jobs}

export PATH=$BOSH_PACKAGES_DIR/ruby_vcloud_cpi/bin:$BOSH_PACKAGES_DIR/bosh_vcloud_cpi_mkisofs/bin:$PATH

export BUNDLE_GEMFILE=$BOSH_PACKAGES_DIR/bosh_vcloud_cpi/Gemfile

bundle_cmd="$BOSH_PACKAGES_DIR/ruby_vcloud_cpi/bin/bundle"

exec $bundle_cmd exec $BOSH_PACKAGES_DIR/bosh_vcloud_cpi/bin/vcloud_cpi \
  $BOSH_JOBS_DIR/vcloud_cpi/config/cpi.json < <(echo $INPUT)

Use `exec` to avoid second bash process
Use `exec` to avoid second bash process

[#119609491](https://www.pivotaltracker.com/story/show/119609491)

Signed-off-by: Felix Riegger <9c2aa7530239a330bbac6ac4f56e0946781dfd29@sap.com>
