scottslowe-learning-tools/etcd-2.0/provision.sh
Paul Czarkowski 78ecd9a3aa fixes and cleanup
* move etcd.overrides to /etc/default/etcd ( more linuxy, upstart script tries to source that already ).
* template etcd.defaults using values from servers.yml
* provision installs curl if doesn't exist ( I use vbox and my base image doesn't have it )
* provision is now roughly idempotent
* provision starts etcd or restarts it if already running
* gitignore to not save template written .default files
2015-04-16 08:55:45 -05:00

35 lines
988 B
Bash

#!/bin/bash
# install curl if needed
if [[ ! -e /usr/bin/curl ]]; then
apt-get update
apt-get -yqq install curl
fi
if [[ ! -e /usr/local/bin/etcd ]]; then
# Get etcd download
curl -sL https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.tar.gz -o etcd-v2.0.9-linux-amd64.tar.gz
# Expand the download
tar xzvf etcd-v2.0.9-linux-amd64.tar.gz
# Move etcd and etcdctl to /usr/local/bin
cd etcd-v2.0.9-linux-amd64
sudo mv etcd /usr/local/bin/
sudo mv etcdctl /usr/local/bin/
cd ..
# Remove etcd download and directory
rm etcd-v2.0.9-linux-amd64.tar.gz
rm -rf etcd-v2.0.9-linux-amd64
# Create directories needed by etcd
sudo mkdir -p /var/etcd
fi
# Copy files into the correct locations; requires shared folders
sudo cp /vagrant/etcd.conf /etc/init/etcd.conf
sudo cp /vagrant/$HOSTNAME.defaults /etc/default/etcd
# restart if already running, otherwise start.
initctl status etcd && initctl restart etcd || initctl start etcd