-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf.sh
executable file
·68 lines (54 loc) · 1.98 KB
/
cf.sh
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
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
# global stuff
# shellcheck source="$script_dir/.envrc"
source "$script_dir/.envrc"
# shellcheck source="$script_dir/lib.sh"
source "$script_dir/lib.sh"
cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}
parse_params() {
# default values of variables set from params
while :; do
case "${1-}" in
-h | --help) usage "Deploy Cloud Foundry under local BOSH director" ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done
return 0
}
parse_params "$@"
setup_colors
# The code
cf_deployment_path="${script_dir}/../cf-deployment"
if [ ! -d "$cf_deployment_path" ]; then
git clone https://github.com/cloudfoundry/cf-deployment.git "$cf_deployment_path"
fi
stemcells_path="$script_dir/stemcells"
stemcell_os=$(bosh interpolate --path=/stemcells/0/os "${cf_deployment_path}/cf-deployment.yml")
stemcell_version=$(bosh interpolate --path=/stemcells/0/version "${cf_deployment_path}/cf-deployment.yml")
stemcell_url="https://bosh.io/d/stemcells/bosh-warden-boshlite-${stemcell_os}-go_agent?v=${stemcell_version}"
stemcell_file="$stemcells_path/bosh-stemcell-${stemcell_version}-warden-boshlite-${stemcell_os}-go_agent.tgz"
if [ ! -f "$stemcell_file" ]; then
wget "${stemcell_url}" --output-document="${stemcell_file}"
fi
bosh -e "$BOSH_ENVIRONMENT" -n upload-stemcell "$stemcell_file"
pushd "$cf_deployment_path"
bosh -e "$BOSH_ENVIRONMENT" -n update-cloud-config iaas-support/bosh-lite/cloud-config.yml
bosh -e "$BOSH_ENVIRONMENT" -n -d cf deploy cf-deployment.yml \
--ops-file=operations/bosh-lite.yml \
--var=system_domain=bosh-lite.com
popd
cf api https://api.bosh-lite.com --skip-ssl-validation
admin_password=$(credhub get -q -n /bosh-lite/cf/cf_admin_password)
cf login -u admin -p "$admin_password"
cf create-space system
cf target -s system