scottslowe-learning-tools/docker-swarm-etcd/provision.sh
Scott S. Lowe 4f0eb76317 Update Docker Swarm-etcd environment
Update the etcd-backed Docker Swarm environment with new methods/techniques learned in building the Vagrant environment. This involves changes to the external YAML file (renamed to "machines.yml") and the Vagrantfile. Only minor changes were made to the ERB template and the provisioning script (to eliminate a dependency on shared folders).

Signed-off-by: Scott S. Lowe <scott.lowe@scottlowe.org>
2016-10-20 16:18:13 -06:00

45 lines
1.1 KiB
Bash

#!/bin/bash
# Define a couple variables for easier future modifications
VERS="v2.3.7"
BASENAME="etcd-$VERS-linux-amd64"
FNAME="$BASENAME.tar.gz"
URL="https://github.com/coreos/etcd/releases/download/$VERS/$FNAME"
# Install curl if needed
if [[ ! -e /usr/bin/curl ]]; then
apt-get update
apt-get -yqq install curl
fi
# Install etcd if not already present
if [[ ! -e /usr/local/bin/etcd ]]; then
# Download the etcd release from GitHub
curl -L $URL -o $FNAME
# Expand the download
tar xzvf $FNAME
# Move etcd and etcdctl to /usr/local/bin
cd $BASENAME
sudo mv etcd /usr/local/bin/
sudo mv etcdctl /usr/local/bin/
cd ..
# Remove etcd download and directory
rm $FNAME
rm -rf $BASENAME
fi
# Create etcd data directory if not already present
if [[ ! -d /var/etcd ]]; then
sudo mkdir /var/etcd
fi
# Copy files into the correct locations; requires shared folders
sudo cp /home/vagrant/etcd.conf /etc/init/etcd.conf
sudo cp /home/vagrant/$HOSTNAME.defaults /etc/default/etcd
# Restart if already running; otherwise, start etcd.
sudo initctl status etcd && initctl restart etcd || initctl start etcd