Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (40 sloc) 1.71 KB
#!/usr/bin/env bash
# Build the resources for the flannel charm including CNI and etcdctl binaries.
# The first argument ($1) should be the Flannel version.
# The second argument ($2) should be the CNI verison.
# The third argument ($3) should be the Etcd version.
set -o errexit # Exit when an individual command fails.
set -o pipefail # The exit status of the last command is returned.
set -o xtrace # Print the commands that are executed.
echo "${0} started at `date`."
FLANNEL_VERSION=${FLANNEL_VERSION:-"v0.9.1"}
OS=${OS:-"linux"}
ARCH=${ARCH:-"amd64"}
SCRIPT_DIR=${PWD}
TEMPORARY_DIRECTORY=${TEMPORARY_DIRECTORY:-"$SCRIPT_DIR/temp"}
mkdir -p $TEMPORARY_DIRECTORY
# Get the function definition for download.
source ./utilities.sh
# Build the CNI binaries for a version, os and arch.
resources/build-cni.sh
# Build the etcd binaries for a version, os and arch.
resources/build-etcd.sh
if [ ! -d flannel ]; then
# Clone the flannel project.
git clone https://github.com/coreos/flannel.git flannel
fi
cd flannel
# Checkout the desired version.
git checkout -f ${FLANNEL_VERSION}
echo "Building flanneld=${ARCH}..."
make dist/flanneld-${ARCH}
cd ..
# Copy the flanneld binary to the temporary directory to archive.
cp -v flannel/dist/flanneld-${ARCH} ${TEMPORARY_DIRECTORY}/${OS}/${ARCH}/flanneld
# Create the flannel resource archive with version, os and architecture.
FLANNEL_ARCHIVE=${SCRIPT_DIR}/flannel-resource-${FLANNEL_VERSION}-${OS}-${ARCH}.tar.gz
echo "Creating the ${FLANNEL_ARCHIVE} file."
FLANNEL_FILES="bridge etcdctl flannel flanneld host-local portmap"
create_archive ${TEMPORARY_DIRECTORY}/${OS}/${ARCH} ${FLANNEL_ARCHIVE} "${FLANNEL_FILES}"
cd ${SCRIPT_DIR}
echo "${0} completed successfully at `date`."