github.hscsec.cn/hashicorp/consul@v1.4.5/terraform/openstack/scripts/install.sh (about) 1 #!/usr/bin/env bash 2 set -e 3 4 # Read the address to join from the file we provisioned 5 JOIN_ADDRS=$(cat /tmp/consul-server-addr | tr -d '\n') 6 7 # consul version to install 8 CONSUL_VERSION=0.6.4 9 10 sudo sh -c 'echo "127.0.0.1 consul-node-'$(cat /tmp/consul-server-index)'" >> /etc/hosts' 11 12 echo "Installing dependencies..." 13 sudo apt-get update -y 14 sudo apt-get install -y unzip 15 16 echo "Fetching Consul..." 17 cd /tmp 18 wget "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" -O consul.zip 19 20 echo "Installing Consul..." 21 unzip consul.zip >/dev/null 22 sudo chmod +x consul 23 sudo mv consul /usr/local/bin/consul 24 sudo mkdir -p /etc/consul.d 25 sudo mkdir -p /mnt/consul 26 sudo mkdir -p /etc/service 27 28 # Setup the join address 29 cat >/tmp/consul-join << EOF 30 export CONSUL_JOIN="${JOIN_ADDRS}" 31 EOF 32 sudo mv /tmp/consul-join /etc/service/consul-join 33 chmod 0644 /etc/service/consul-join 34 35 echo "Installing Upstart service..." 36 sudo mv /tmp/upstart.conf /etc/init/consul.conf 37 sudo mv /tmp/upstart-join.conf /etc/init/consul-join.conf