Content-Type: multipart/mixed; boundary="//" MIME-Version: 1.0 --// Content-Type: text/cloud-config; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config.txt" #cloud-config cloud_final_modules: - [scripts-user, always] --// Content-Type: text/x-shellscript; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="userdata.txt" #!/bin/bash HFE_DIR="/home/ubuntu/HFE" HFE_LOG_DIR="$HFE_DIR/log" HFE_FILE="$HFE_DIR/HFE_GCE.sh" LOG_FILE="$HFE_LOG_DIR/cloud-init-nat.log" NAT_VAR="$HFE_DIR/natVars.input" timestamp() { date +"%Y-%m-%d %T" } if [ ! -d $HFE_LOG_DIR ]; then mkdir -p $HFE_LOG_DIR; fi; /bin/echo $(timestamp) " ========================= cloud-init configuration for HFE ==========================================" >> $LOG_FILE if [ $(grep -c 169.254.169.254 /etc/resolv.conf) -eq 0 ]; then sed -i.orig '/^nameserver.*/i nameserver 169.254.169.254' /etc/resolv.conf fi gsutil cp gs:// $HFE_FILE if [ $? -ne 0 ]; then /bin/echo $(timestamp) "Error:Could not copy HFE script from Google Storage." >> $LOG_FILE else /bin/echo $(timestamp) "Copied HFE script from Google Storage." >> $LOG_FILE fi; /bin/echo > $NAT_VAR /bin/echo "ACTIVE_SBC_VM_NAME=\"\"" >> $NAT_VAR /bin/echo "STANDBY_SBC_VM_NAME=\"\"" >> $NAT_VAR /bin/echo "REMOTE_SSH_MACHINE_IP=\"\"">> $NAT_VAR /bin/echo "ZONE=\"\"">> $NAT_VAR /bin/echo $(timestamp) "Copied natVars.input" >> $LOG_FILE sudo chmod 744 $HFE_FILE /bin/echo "Configured using HFE script - $HFE_FILE" >> $LOG_FILE /bin/echo $(timestamp) " ========================= Done ==========================================" >> $LOG_FILE nohup $HFE_FILE setup > /dev/null 2>&1 & --//