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
+
3
7
set -euo pipefail
4
8
5
9
# ensure this script wasn't called from the directory where this script
@@ -10,126 +14,73 @@ if [ "$script_dir" == "." ]; then
10
14
exit 1
11
15
fi
12
16
13
- DEV_IMAGE_NAME=" devbuild"
14
- VERSION=${BUILD_VERSION-$DEV_IMAGE_NAME }
15
-
16
- contiv_version=${CONTIV_VERSION:- " 1.0.3" }
17
17
pull_images=${CONTIV_CI_HOST:- " false" }
18
18
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 }
19
+ ansible_image_version=${CONTIV_ANSIBLE_IMAGE_VERSION:- $DEFAULT_DOWNLOAD_CONTIV_VERSION }
20
+ auth_proxy_version=${CONTIV_API_PROXY_VERSION:- $DEFAULT_DOWNLOAD_CONTIV_VERSION }
21
21
docker_version=${CONTIV_DOCKER_VERSION:- 1.12.6}
22
22
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
23
26
24
# the installer currently pulls the v2plugin image directly from Docker Hub, but
27
25
# this will change to being downloaded from the Docker Store in the future.
28
26
# because of this, the default value for this variable will become the latest
29
27
# version that is available in the Docker Store and should be considered
30
28
# independent of $contiv_version above.
31
- v2plugin_version=${CONTIV_V2PLUGIN_VERSION:- " 1.0.3 " }
29
+ v2plugin_version=${CONTIV_V2PLUGIN_VERSION:- " 1.1.5 " }
32
30
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
- }
31
+ # where everything is assembled, always start with a clean dir and clean it up
32
+ output_tmp_dir= " $( mktemp -d ) "
33
+ output_dir= " ${output_tmp_dir} / contiv- ${CONTIV_INSTALLER_VERSION} "
34
+ mkdir -p ${output_dir}
35
+ trap ' rm -rf ${output_tmp_dir} ' EXIT
38
36
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
37
+ release_dir=release
38
+ mkdir -p $release_dir
39
+ output_file=" ${release_dir} /contiv-${CONTIV_INSTALLER_VERSION} .tgz"
40
+ full_output_file=" $release_dir /contiv-full-${CONTIV_INSTALLER_VERSION} .tgz"
82
41
83
42
# Release files
84
43
# k8s - install.sh to take the args and construct contiv.yaml as required and to launch kubectl
85
44
# swarm - install.sh launches the container to do the actual installation
86
45
# 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
46
+ cp -rf install README.md $output_dir
90
47
cp -rf scripts/generate-certificate.sh $output_dir /install
91
48
92
49
# Get the ansible support files
93
50
chmod +x $output_dir /install/genInventoryFile.py
94
51
chmod +x $output_dir /install/generate-certificate.sh
95
52
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
53
+ cp -a ${CONTIV_ARTIFACT_STAGING} /ansible ${output_dir} /
106
54
107
55
# Replace versions
108
56
files=$( find $output_dir -type f -name " *.yaml" -or -name " *.sh" -or -name " *.json" )
109
57
sed -i.bak " s/__ACI_GW_VERSION__/$aci_gw_version /g" $files
110
58
sed -i.bak " s/__API_PROXY_VERSION__/$auth_proxy_version /g" $files
111
59
sed -i.bak " s/__CONTIV_INSTALL_VERSION__/$ansible_image_version /g" $files
112
- sed -i.bak " s/__CONTIV_VERSION__/$contiv_version /g" $files
60
+ sed -i.bak " s/__CONTIV_VERSION__/$CONTIV_NETPLUGIN_VERSION /g" $files
113
61
sed -i.bak " s/__DOCKER_VERSION__/$docker_version /g" $files
114
62
sed -i.bak " s/__ETCD_VERSION__/$etcd_version /g" $files
115
63
sed -i.bak " s/__CONTIV_V2PLUGIN_VERSION__/$v2plugin_version /g" $files
116
64
117
65
# Make all shell script files executable
118
66
chmod +x $( find $output_dir -type f -name " *.sh" )
119
67
120
- # Cleanup the backup files
121
- rm -rf $output_dir /scripts
122
- rm -rf $( find $output_dir -type f -name " *.bak" )
123
-
124
68
# Clean up the Dockerfile, it is not part of the release bits.
125
69
rm -f $output_dir /install/ansible/Dockerfile
126
70
127
71
# Create the binary cache folder
128
72
binary_cache=$output_dir /contiv_cache
129
73
mkdir -p $binary_cache
130
74
131
- # Create the minimal tar bundle
132
- tar czf $tmp_output_file -C $release_dir contiv-$VERSION
75
+ # only build installer that pulls artifacts over internet if not building
76
+ # a specific commit of netplugin
77
+ if [ -z " ${NETPLUGIN_BRANCH:- } " ]; then
78
+ # Create the minimal tar bundle
79
+ tar czf $output_file -C $output_tmp_dir contiv-${CONTIV_INSTALLER_VERSION}
80
+ echo -n " Contiv Installer version '$CONTIV_INSTALLER_VERSION ' with "
81
+ echo " netplugin version '$CONTIV_NETPLUGIN_VERSION ' is available "
82
+ echo " at '$output_file '"
83
+ fi
133
84
134
85
# Save the auth proxy & aci-gw images for packaging the full docker images with contiv install binaries
135
86
if [[ " $( docker images -q contiv/auth_proxy:$auth_proxy_version 2> /dev/null) " == " " || " $pull_images " == " true" ]]; then
@@ -147,15 +98,27 @@ curl --fail -sL -o $binary_cache/openvswitch-2.5.0-2.el7.x86_64.rpm http://cbs.c
147
98
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
99
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
100
101
+ # Copy the netplugin release into the binary cache for "full" installer
102
+ # Netplugin releases built locally based on a branch are named by their SHA,
103
+ # but there is a symlink to point to the SHA named tarball by it's branch name
104
+ plugin_tball=${CONTIV_ARTIFACT_STAGING} /$CONTIV_NETPLUGIN_TARBALL_NAME
105
+ if [[ -L " ${plugin_tball} " ]]; then
106
+ # copy the link (so other processes can find the tarball) and the tarball
107
+ target_plugin_tball=$( readlink ${plugin_tball} )
108
+ cp -a ${plugin_tball} ${binary_cache} /
109
+ plugin_tball=${CONTIV_ARTIFACT_STAGING} /${target_plugin_tball}
110
+ fi
111
+ cp ${plugin_tball} ${binary_cache} /
112
+
150
113
env_file=$output_dir /install/ansible/env.json
151
114
sed -i.bak " s#.*auth_proxy_local_install.*# \" auth_proxy_local_install\" : True,#g" $env_file
152
115
sed -i.bak " s#.*contiv_network_local_install.*# \" contiv_network_local_install\" : True,#g" $env_file
153
116
154
117
# Create the full tar bundle
155
- tar czf $tmp_full_output_file -C $release_dir contiv-$VERSION
156
-
157
- mv $tmp_output_file $output_file
158
- mv $tmp_full_output_file $full_output_file
159
- rm -rf $output_dir
160
-
161
- echo " Success: Contiv Installer version $VERSION is available at $output_file "
118
+ tar czf $full_output_file -C $output_tmp_dir contiv-${CONTIV_INSTALLER_VERSION}
119
+ echo -n " Contiv Installer version ' $CONTIV_INSTALLER_VERSION ' with "
120
+ echo " netplugin version ' $CONTIV_NETPLUGIN_VERSION ' is available "
121
+ echo " at ' $full_output_file ', it includes all contiv assets "
122
+ echo " required for installation "
123
+ echo
124
+ echo -e " \nSuccess "
0 commit comments