#!/bin/bash set -euo pipefail cd ~/code/build-instance terraform apply -auto-approve -var region=us-east-2 -var myip=$(curl ifconfig.me) PUBLIC_IP="$(terraform output -raw public_ipv4_address)" tmp_file="$(mktemp)" awk -v ipaddr=$PUBLIC_IP '/^Host builder$/ {f=1; print; next} f {$2=ipaddr; f=0; print " "$0; next} 1' ~/.ssh/config > "${tmp_file}" mv -f "${tmp_file}" ~/.ssh/config chmod 0400 ~/.ssh/config echo "Waiting for builder instance to be ready" while ! ssh builder test -d hypershift.git 2> /dev/null; do sleep 5 done echo "Copying files to builder instance..." scp ./post-receive builder:hypershift.git/hooks/post-receive ssh builder chmod +x hypershift.git/hooks/post-receive scp ./pull-secret builder:.pull-secret echo "Builder instance is ready"