-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathpost-start.sh.erb
73 lines (56 loc) · 1.85 KB
/
post-start.sh.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
<%
def discover_external_ip
networks = spec.networks.marshal_dump
_, network = networks.find do |_name, network_spec|
network_spec.default
end
if !network
_, network = networks.first
end
if !network
raise "Could not determine IP address via network spec: #{networks}"
end
network.ip
end
%>
set -ex
export LANG="en_US.UTF-8"
CC_JOB_DIR="/var/vcap/jobs/cloud_controller_ng"
CONFIG_DIR="${CC_JOB_DIR}/config"
CC_PACKAGE_DIR="/var/vcap/packages/cloud_controller_ng"
export CLOUD_CONTROLLER_NG_CONFIG="${CONFIG_DIR}/cloud_controller_ng.yml"
export BUNDLE_GEMFILE="${CC_PACKAGE_DIR}/cloud_controller_ng/Gemfile"
source "${CC_JOB_DIR}/bin/ruby_version.sh"
source /var/vcap/packages/capi_utils/syslog_utils.sh
source /var/vcap/packages/capi_utils/monit_utils.sh
tee_output_to_sys_log "cloud_controller_ng.$(basename "$0")"
function fix_bundler_home_permissions {
BUNDLER_DIR1=/tmp/bundler
BUNDLER_DIR2=/var/vcap/data/cloud_controller_ng/tmp/bundler
chpst -u vcap:vcap mkdir -p $BUNDLER_DIR1 $BUNDLER_DIR2
chown vcap:vcap -R $BUNDLER_DIR1 $BUNDLER_DIR2
chpst -u vcap:vcap chmod -R go-w $BUNDLER_DIR1 $BUNDLER_DIR2
chpst -u vcap:vcap chmod -R +t $BUNDLER_DIR1 $BUNDLER_DIR2
}
function install_buildpacks {
<% if spec.bootstrap %>
pushd "${CC_PACKAGE_DIR}/cloud_controller_ng" > /dev/null
chpst -u vcap:vcap bundle exec rake buildpacks:install
if [[ $? -ne 0 ]]; then
echo "Buildpacks installation failed"
exit 1
fi
popd > /dev/null
<% else %>
echo "Skipping buildpack installation"
<% end %>
}
function main {
install_buildpacks
fix_bundler_home_permissions
}
main
PORT=<%= p("cc.public_tls.port") %>
wait_for_server_to_become_healthy "https://<%= discover_external_ip %>:${PORT}/healthz" "<%= p("cc.api_post_start_healthcheck_timeout_in_seconds") %>"
exit 0