Created
June 26, 2015 16:34
-
-
Save benschw/8c71f5e3e7f175d2c1f8 to your computer and use it in GitHub Desktop.
script to bootstrap a single node consul service (e.g. for vagrant)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -f /tmp/provisioned ]; then | |
apt-get update | |
apt-get install -y daemon wget unzip | |
touch /tmp/provisioned | |
fi | |
if [ -f "/usr/local/bin/consul" ]; then | |
echo consul already installed | |
else | |
wget https://dl.bintray.com/mitchellh/consul/0.5.2_linux_amd64.zip -O /tmp/consul.zip 2&>1 > /dev/null | |
unzip /tmp/consul.zip -d /usr/local/bin/ | |
chmod 755 /usr/local/bin/consul | |
rm /tmp/consul.zip | |
fi | |
if [ -d "/opt/consul/web/dist" ]; then | |
echo consul ui already installed | |
else | |
mkdir -p /opt/consul/web | |
wget https://dl.bintray.com/mitchellh/consul/0.5.2_web_ui.zip -O /tmp/consul-ui.zip 2&>1 > /dev/null | |
unzip /tmp/consul-ui.zip -d /opt/consul/web/ | |
rm /tmp/consul-ui.zip | |
fi | |
if pgrep "consul" > /dev/null; then | |
echo consul already running | |
else | |
mkdir -p /opt/consul/data | |
daemon -X "consul agent -server -client=0.0.0.0 -ui-dir /opt/consul/web/dist -data-dir /opt/consul/data -bind 0.0.0.0 -syslog -bootstrap-expect 1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment