#!/bin/bash

# AWS Worker Bootstrap File # File used to configure worker nodes on AWS

# Change Host File Entries ENTRY=“SERVER_IP SERVER_HOSTNAME” FILE=/etc/hosts if grep -q “$ENTRY” $FILE; then

echo "entry already exists"

else

sh -c "echo $ENTRY >> $FILE"

fi

WORKER_PUBLIC_KEY=“WORKER_PUBLIC_KEY_TEMPLATE”

# add the public key to authorized keys USER=ubuntu

mkdir -p /home/$USER/.ssh && chmod 700 /home/$USER/.ssh

# Only access from the server node ENTRY=“from="SERVER_HOSTNAME" $WORKER_PUBLIC_KEY” FILE=/home/$USER/.ssh/authorized_keys if grep -q “$ENTRY” $FILE; then

echo "Key already exists in file"

else

echo $ENTRY >> $FILE

fi chmod 644 /home/$USER/.ssh/authorized_keys

# ec2 instance information curl -o /usr/local/bin/ec2-metadata s3.amazonaws.com/ec2metadata/ec2-metadata chmod 775 /usr/local/bin/ec2-metadata mkdir -p /etc/openstudio-server ec2-metadata -a -i -t -h -o -z -p -v > /etc/openstudio-server/instance.yml

file flag the user_data has completed cat /dev/null > /home/ubuntu/user_data_done