#!/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 -r INPUT

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

PATH=$BOSH_PACKAGES_DIR/ruby_openstack_cpi/bin:$PATH
export PATH

export BUNDLE_GEMFILE=$BOSH_PACKAGES_DIR/bosh_openstack_cpi/Gemfile

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

echo $INPUT | $bundle_cmd exec $BOSH_PACKAGES_DIR/bosh_openstack_cpi/bin/openstack_cpi \
$BOSH_JOBS_DIR/openstack_cpi/config/cpi.json \
$BOSH_JOBS_DIR/openstack_cpi/config/cacert.pem

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 -r INPUT

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

PATH=$BOSH_PACKAGES_DIR/ruby_openstack_cpi/bin:$PATH
export PATH

export BUNDLE_GEMFILE=$BOSH_PACKAGES_DIR/bosh_openstack_cpi/Gemfile

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

exec $bundle_cmd exec $BOSH_PACKAGES_DIR/bosh_openstack_cpi/bin/openstack_cpi \
  $BOSH_JOBS_DIR/openstack_cpi/config/cpi.json \
  $BOSH_JOBS_DIR/openstack_cpi/config/cacert.pem < <(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>
