-
Notifications
You must be signed in to change notification settings - Fork 0
/
destroy.sh
executable file
·69 lines (58 loc) · 1.64 KB
/
destroy.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
69
#!/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/lib.sh"
source "$script_dir/lib.sh"
state="$script_dir/bosh-state.json"
creds="$script_dir/bosh-vars-store.yml"
deployment_vars="$script_dir/bosh-deployment-vars.yml"
cpi_override="$script_dir/ops/cpi_override.yml"
cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
rm -f "$script_dir/.envrc" "$state" "$creds" "$deployment_vars"
}
parse_params() {
# default values of variables set from params
while :; do
case "${1-}" in
-h | --help) usage "Destroy 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
if [ -f "$script_dir/.envrc" ]; then
# shellcheck source="$script_dir/.envrc"
source "$script_dir/.envrc"
else
exit 0
fi
bosh_deployment_path="$script_dir/../bosh-deployment"
if [ ! -d "$bosh_deployment_path" ]; then
git clone https://github.com/cloudfoundry/bosh-deployment.git "$script_dir/../bosh-deployment"
fi
pushd "$bosh_deployment_path"
bosh delete-env ./bosh.yml \
--state "$state" \
--ops-file=./virtualbox/cpi.yml \
--ops-file=./virtualbox/outbound-network.yml \
--ops-file=./bosh-lite.yml \
--ops-file=./bosh-lite-runc.yml \
--ops-file=./uaa.yml \
--ops-file=./credhub.yml \
--ops-file=./jumpbox-user.yml \
--ops-file=./misc/dns-addon.yml \
--ops-file="$cpi_override" \
--vars-store="$creds" \
--vars-store="$deployment_vars"
popd