-
Notifications
You must be signed in to change notification settings - Fork 2
/
mongo_bosh_release_dev
executable file
·130 lines (112 loc) · 2.67 KB
/
mongo_bosh_release_dev
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
set -e
fail() { echo -e "$*" ; exit 1 ; }
bosh_cli_check() {
if ! command -v bosh &>/dev/null
then fail "'bosh' command was not found in your path, please 'gem install bosh_cli' and try again."
fi
}
bosh_target_check() {
boshTarget=$(bosh target 2>&1)
case "${boshTarget}" in
(Current\ target\ is*)
echo ${boshTarget}
;;
(*)
fail "A bosh director is not targeted, please target a director and login then try again."
;;
esac
}
spruce_check() {
if ! command -v spruce &>/dev/null
then fail "spruce is not installed. Please download at https://github.com/geofffranks/spruce/releases"
fi
}
usage() {
echo "
Usage: $0 <prepare|blobs|release> [options]
Where [options] for the 'prepare', 'manifest' actions are:
'aws-ec2', 'openstack', 'vsphere' or 'warden'
"
}
select_infrastructure() {
if [ "$infrastructure" != "aws-ec2" ] && \
[ "$infrastructure" != "openstack" ] && \
[ "$infrastructure" != "vsphere" ] && \
[ "$infrastructure" != "warden" ]; then
usage
fail
fi
}
prepare_blobs() {
[ -d "${releasePath}/blobs" ] || mkdir "${releasePath}/blobs"
echo "Preparing all packages..."
git submodule update --init --recursive
#find -path './packages/*' -name prepare -type f -exec bash -c "[ -s ${releasePath}/blobs/${0:2} ] && ( echo $releasePath/blobs/${0:2}; cd ${releasePath}/blobs ; $SHELL ${releasePath}/${0:2} )" {} \;
for prep in $(find -path './packages/*' -name prepare -type f)
do
if [ -s ${prep} ]
then
echo ${prep}
( cd ${releasePath}/blobs ; ${SHELL} ${releasePath}/${prep} )
else
echo Could not find ${prep}
fi
done
}
prepare_dev_release() {
echo "bosh create release --with-tarball --force"
bosh create release --with-tarball --force
echo "bosh -n upload release"
bosh -n upload release
}
gen_manifest() {
spruce merge --prune meta \
$templatesPath/deployment.yml \
$templatesPath/jobs.yml \
$templatesPath/infrastructure-${infrastructure}.yml \
$templatesPath/properties.yml \
$templatesPath/stub.yml \
$* \
> ~/cf-mongo.yml
bosh deployment ~/cf-mongo.yml
}
releasePath=$(cd $(dirname $0) ; echo $PWD)
templatesPath="${releasePath}/templates"
if (( $# > 0 ))
then
action=$1
infrastructure=$2
shift
else
usage
fail
fi
bosh_target_check
bosh_cli_check
spruce_check
declare -a args
if (( ${#@} ))
then args=($(echo "${@}"))
fi
case ${action} in
(prepare)
prepare_blobs
prepare_dev_release
;;
(release)
prepare_dev_release
;;
(blobs)
prepare_blobs
;;
(manifest)
select_infrastructure
gen_manifest
;;
(*)
usage
fail "Unknown action ${action}."
;;
esac
exit 0