github.com/smithx10/nomad@v0.9.1-rc1/e2e/terraform/shared/scripts/server.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 CONFIGDIR=/ops/shared/config 6 7 CONSULCONFIGDIR=/etc/consul.d 8 VAULTCONFIGDIR=/etc/vault.d 9 NOMADCONFIGDIR=/etc/nomad.d 10 HADOOP_VERSION=hadoop-2.7.6 11 HADOOPCONFIGDIR=/usr/local/$HADOOP_VERSION/etc/hadoop 12 HOME_DIR=ubuntu 13 14 # Wait for network 15 sleep 15 16 17 # IP_ADDRESS=$(curl http://instance-data/latest/meta-data/local-ipv4) 18 IP_ADDRESS="$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')" 19 DOCKER_BRIDGE_IP_ADDRESS=(`ifconfig docker0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`) 20 CLOUD=$1 21 SERVER_COUNT=$2 22 RETRY_JOIN=$3 23 24 # Consul 25 sed -i "s/IP_ADDRESS/$IP_ADDRESS/g" $CONFIGDIR/consul.json 26 sed -i "s/SERVER_COUNT/$SERVER_COUNT/g" $CONFIGDIR/consul.json 27 sed -i "s/RETRY_JOIN/$RETRY_JOIN/g" $CONFIGDIR/consul.json 28 sudo cp $CONFIGDIR/consul.json $CONSULCONFIGDIR 29 sudo cp $CONFIGDIR/consul_$CLOUD.service /etc/systemd/system/consul.service 30 31 sudo systemctl start consul.service 32 sleep 10 33 export CONSUL_HTTP_ADDR=$IP_ADDRESS:8500 34 export CONSUL_RPC_ADDR=$IP_ADDRESS:8400 35 36 # Vault 37 sed -i "s/IP_ADDRESS/$IP_ADDRESS/g" $CONFIGDIR/vault.hcl 38 sudo cp $CONFIGDIR/vault.hcl $VAULTCONFIGDIR 39 sudo cp $CONFIGDIR/vault.service /etc/systemd/system/vault.service 40 41 sudo systemctl start vault.service 42 43 export NOMAD_ADDR=http://$IP_ADDRESS:4646 44 45 # Add hostname to /etc/hosts 46 echo "127.0.0.1 $(hostname)" | sudo tee --append /etc/hosts 47 48 # Add Docker bridge network IP to /etc/resolv.conf (at the top) 49 50 echo "nameserver $DOCKER_BRIDGE_IP_ADDRESS" | sudo tee /etc/resolv.conf.new 51 cat /etc/resolv.conf | sudo tee --append /etc/resolv.conf.new 52 sudo mv /etc/resolv.conf.new /etc/resolv.conf 53 54 # Hadoop 55 sudo cp $CONFIGDIR/core-site.xml $HADOOPCONFIGDIR 56 57 # Move examples directory to $HOME 58 sudo mv /ops/examples /home/$HOME_DIR 59 sudo chown -R $HOME_DIR:$HOME_DIR /home/$HOME_DIR/examples 60 sudo chmod -R 775 /home/$HOME_DIR/examples 61 62 # Set env vars for tool CLIs 63 echo "export CONSUL_RPC_ADDR=$IP_ADDRESS:8400" | sudo tee --append /home/$HOME_DIR/.bashrc 64 echo "export CONSUL_HTTP_ADDR=$IP_ADDRESS:8500" | sudo tee --append /home/$HOME_DIR/.bashrc 65 echo "export VAULT_ADDR=http://$IP_ADDRESS:8200" | sudo tee --append /home/$HOME_DIR/.bashrc 66 echo "export NOMAD_ADDR=http://$IP_ADDRESS:4646" | sudo tee --append /home/$HOME_DIR/.bashrc 67 echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre" | sudo tee --append /home/$HOME_DIR/.bashrc 68 69 # Update PATH 70 echo "export PATH=$PATH:/usr/local/bin/spark/bin:/usr/local/$HADOOP_VERSION/bin" | sudo tee --append /home/$HOME_DIR/.bashrc