1
1
#! /bin/bash
2
2
3
+ # Required environment variables:
4
+ # * CONTIV_INSTALLER_VERSION - sets the tarball artifact filenames
5
+ # * CONTIV_NETPLUGIN_VERSION - updates config files to locate contiv tarball
6
+ # * CONTIV_V2PLUGIN_VERSION - which v2plugin version to download during install
7
+
3
8
set -xeuo pipefail
4
9
5
10
# ensure this script wasn't called from the directory where this script
@@ -10,126 +15,67 @@ if [ "$script_dir" == "." ]; then
10
15
exit 1
11
16
fi
12
17
13
- DEV_IMAGE_NAME=" devbuild"
14
- VERSION=${BUILD_VERSION-$DEV_IMAGE_NAME }
15
-
16
- contiv_version=${CONTIV_VERSION:- " 1.0.3" }
17
18
pull_images=${CONTIV_CI_HOST:- " false" }
18
19
aci_gw_version=${CONTIV_ACI_GW_VERSION:- " latest" }
19
- ansible_image_version=${CONTIV_ANSIBLE_IMAGE_VERSION:- $contiv_version }
20
- auth_proxy_version=${CONTIV_API_PROXY_VERSION:- $contiv_version }
20
+ ansible_image_version=${CONTIV_ANSIBLE_IMAGE_VERSION:- $DEFAULT_DOWNLOAD_CONTIV_VERSION }
21
+ auth_proxy_version=${CONTIV_API_PROXY_VERSION:- $DEFAULT_DOWNLOAD_CONTIV_VERSION }
21
22
docker_version=${CONTIV_DOCKER_VERSION:- 1.12.6}
22
23
etcd_version=${CONTIV_ETCD_VERSION:- v2.3.8}
23
- contiv_ansible_commit=${CONTIV_ANSIBLE_COMMIT:- 4e67f54a8042debfc3d8b504046d0a1d4ea38c37}
24
- contiv_ansible_owner=${CONTIV_ANSIBLE_OWNER:- contiv}
25
-
26
- # the installer currently pulls the v2plugin image directly from Docker Hub, but
27
- # this will change to being downloaded from the Docker Store in the future.
28
- # because of this, the default value for this variable will become the latest
29
- # version that is available in the Docker Store and should be considered
30
- # independent of $contiv_version above.
31
- v2plugin_version=${CONTIV_V2PLUGIN_VERSION:- " 1.0.3" }
32
-
33
- function usage() {
34
- echo " Usage:"
35
- echo " ./release.sh -a <ACI gateway image> -c <contiv version> -e <etcd version> -p <API proxy image version> "
36
- exit 1
37
- }
24
+ v2plugin_version=${CONTIV_V2PLUGIN_VERSION}
38
25
39
- function error_ret() {
40
- echo " "
41
- echo $1
42
- exit 1
43
- }
44
-
45
- while getopts " :a:p:c:e:v:" opt; do
46
- case $opt in
47
- a)
48
- aci_gw_version=$OPTARG
49
- ;;
50
- c)
51
- contiv_version=$OPTARG
52
- ;;
53
- e)
54
- etcd_version=$OPTARG
55
- ;;
56
- p)
57
- auth_proxy_version=$OPTARG
58
- ;;
59
- v)
60
- v2plugin_version=$OPTARG
61
- ;;
62
- :)
63
- echo " An argument required for $OPTARG was not passed"
64
- usage
65
- ;;
66
- ? )
67
- usage
68
- ;;
69
- esac
70
- done
71
-
72
- release_dir=" release"
73
- output_dir=" $release_dir /contiv-$VERSION /"
74
- output_file=" $release_dir /contiv-$VERSION .tgz"
75
- tmp_output_file=" contiv-$VERSION .tgz"
76
- full_output_file=" $release_dir /contiv-full-$VERSION .tgz"
77
- tmp_full_output_file=" contiv-full-$VERSION .tgz"
78
-
79
- # Clean older dist folders and release binaries
80
- rm -rf $output_dir
81
- rm -rf $output_file
26
+ # where everything is assembled, always start with a clean dir and clean it up
27
+ output_tmp_dir=" $( mktemp -d) "
28
+ output_dir=" ${output_tmp_dir} /contiv-${CONTIV_INSTALLER_VERSION} "
29
+ mkdir -p ${output_dir}
30
+ trap ' rm -rf ${output_tmp_dir}' EXIT
31
+
32
+ release_dir=release
33
+ mkdir -p $release_dir
34
+ output_file=" ${release_dir} /contiv-${CONTIV_INSTALLER_VERSION} .tgz"
35
+ full_output_file=" $release_dir /contiv-full-${CONTIV_INSTALLER_VERSION} .tgz"
82
36
83
37
# Release files
84
38
# k8s - install.sh to take the args and construct contiv.yaml as required and to launch kubectl
85
39
# swarm - install.sh launches the container to do the actual installation
86
40
# Top level install.sh which will either take k8s/swarm install params and do the required.
87
- mkdir -p $output_dir
88
- cp -rf install $output_dir
89
- cp README.md $output_dir
41
+ cp -rf install README.md $output_dir
90
42
cp -rf scripts/generate-certificate.sh $output_dir /install
91
43
92
44
# Get the ansible support files
93
45
chmod +x $output_dir /install/genInventoryFile.py
94
46
chmod +x $output_dir /install/generate-certificate.sh
95
47
96
- # This is maybe optional - but assume we need it for
97
- curl -sSL https://github.com/contiv/netplugin/releases/download/$contiv_version /netplugin-$contiv_version .tar.bz2 -o $output_dir /netplugin-$contiv_version .tar.bz2
98
- pushd $output_dir
99
- tar oxf netplugin-$contiv_version .tar.bz2 netctl
100
- rm -f netplugin-$contiv_version .tar.bz2
101
- popd
102
- # add ansible repo contents where final tarball will include
103
- mkdir $output_dir /ansible
104
- curl -sL https://api.github.com/repos/${contiv_ansible_owner} /ansible/tarball/$contiv_ansible_commit |
105
- tar --strip-components 1 -C $output_dir /ansible -z -x
48
+ cp -a ${CONTIV_ARTIFACT_STAGING} /ansible ${output_dir} /
106
49
107
50
# Replace versions
108
51
files=$( find $output_dir -type f -name " *.yaml" -or -name " *.sh" -or -name " *.json" )
109
52
sed -i.bak ' s/__ACI_GW_VERSION__/' " $aci_gw_version " ' /g' $files
110
53
sed -i.bak ' s/__API_PROXY_VERSION__/' " $auth_proxy_version " ' /g' $files
111
54
sed -i.bak ' s/__CONTIV_INSTALL_VERSION__/' " $ansible_image_version " ' /g' $files
112
- sed -i.bak ' s/__CONTIV_VERSION__/' " $contiv_version " ' /g' $files
55
+ sed -i.bak ' s/__CONTIV_VERSION__/' " $CONTIV_NETPLUGIN_VERSION " ' /g' $files
113
56
sed -i.bak ' s/__DOCKER_VERSION__/' " $docker_version " ' /g' $files
114
57
sed -i.bak ' s/__ETCD_VERSION__/' " $etcd_version " ' /g' $files
115
58
sed -i.bak ' s/__CONTIV_V2PLUGIN_VERSION__/' " $v2plugin_version " ' /g' $files
116
59
117
60
# Make all shell script files executable
118
61
chmod +x $( find $output_dir -type f -name " *.sh" )
119
62
120
- # Cleanup the backup files
121
- rm -rf $output_dir /scripts
122
- rm -rf $( find $output_dir -type f -name " *.bak" )
123
-
124
63
# Clean up the Dockerfile, it is not part of the release bits.
125
64
rm -f $output_dir /install/ansible/Dockerfile
126
65
127
66
# Create the binary cache folder
128
67
binary_cache=$output_dir /contiv_cache
129
68
mkdir -p $binary_cache
130
69
131
- # Create the minimal tar bundle
132
- tar czf $tmp_output_file -C $release_dir contiv-$VERSION
70
+ # only build installer that pulls artifacts over internet if not building
71
+ # a specific commit of netplugin
72
+ if [ -z " ${NETPLUGIN_BRANCH:- } " ]; then
73
+ # Create the minimal tar bundle
74
+ tar czf $output_file -C $output_tmp_dir contiv-${CONTIV_INSTALLER_VERSION}
75
+ echo -n " Contiv Installer version '$CONTIV_INSTALLER_VERSION ' with "
76
+ echo " netplugin version '$CONTIV_NETPLUGIN_VERSION ' is available "
77
+ echo " at '$output_file '"
78
+ fi
133
79
134
80
# Save the auth proxy & aci-gw images for packaging the full docker images with contiv install binaries
135
81
if [[ " $( docker images -q contiv/auth_proxy:$auth_proxy_version 2> /dev/null) " == " " || " $pull_images " == " true" ]]; then
@@ -147,17 +93,29 @@ curl --fail -sL -o $binary_cache/openvswitch-2.5.0-2.el7.x86_64.rpm http://cbs.c
147
93
curl --fail -sL -o $binary_cache /ovs-common.deb http://mirrors.kernel.org/ubuntu/pool/main/o/openvswitch/openvswitch-common_2.5.2-0ubuntu0.16.04.3_amd64.deb
148
94
curl --fail -sL -o $binary_cache /ovs-switch.deb http://mirrors.kernel.org/ubuntu/pool/main/o/openvswitch/openvswitch-switch_2.5.2-0ubuntu0.16.04.3_amd64.deb
149
95
96
+ # Copy the netplugin release into the binary cache for "full" installer
97
+ # Netplugin releases built locally based on a branch are named by their SHA,
98
+ # but there is a symlink to point to the SHA named tarball by it's branch name
99
+ plugin_tball=${CONTIV_ARTIFACT_STAGING} /$CONTIV_NETPLUGIN_TARBALL_NAME
100
+ if [[ -L " ${plugin_tball} " ]]; then
101
+ # copy the link (so other processes can find the tarball) and the tarball
102
+ target_plugin_tball=$( readlink ${plugin_tball} )
103
+ cp -a ${plugin_tball} ${binary_cache} /
104
+ plugin_tball=${CONTIV_ARTIFACT_STAGING} /${target_plugin_tball}
105
+ fi
106
+ cp ${plugin_tball} ${binary_cache} /
107
+
150
108
env_file=$output_dir /install/ansible/env.json
151
109
sed -i.bak ' s#__AUTH_PROXY_LOCAL_INSTALL__#true#g' " $env_file "
152
110
sed -i.bak ' s#__CONTIV_NETWORK_LOCAL_INSTALL__#true#g' " $env_file "
153
111
154
112
echo " Ansible extra vars from env.json:"
155
113
cat $env_file
156
114
# Create the full tar bundle
157
- tar czf $tmp_full_output_file -C $release_dir contiv-$VERSION
158
-
159
- mv $tmp_output_file $output_file
160
- mv $tmp_full_output_file $full_output_file
161
- rm -rf $output_dir
162
-
163
- echo " Success: Contiv Installer version $VERSION is available at $output_file "
115
+ tar czf $full_output_file -C $output_tmp_dir contiv-${CONTIV_INSTALLER_VERSION}
116
+ echo -n " Contiv Installer version ' $CONTIV_INSTALLER_VERSION ' with "
117
+ echo " netplugin version ' $CONTIV_NETPLUGIN_VERSION ' is available "
118
+ echo " at ' $full_output_file ', it includes all contiv assets "
119
+ echo " required for installation "
120
+ echo
121
+ echo -e " \nSuccess "
0 commit comments