github.com/smithx10/nomad@v0.9.1-rc1/e2e/terraform/shared/scripts/client.sh (about)

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