blob: 16f7daa25145e7fc0a718aedd4943b7f8a022c9e [file] [log] [blame]
#!/bin/bash
set -x
# Ensure that we only run on production machines.
if [[ $(hostname) != buildkite* ]]; then
echo "Not running, because our hostname does not indicate a production system..."
sleep 60
exit 1
fi
OS_VERSION=$(sw_vers -productVersion)
XCODE_VERSION=$(xcodebuild -version | grep ^Xcode | awk '{print $2}')
MACHINE_TYPE=$(system_profiler SPHardwareDataType | grep 'Model Name' | cut -d':' -f2 | tr -d ' ' | tr '[:upper:]' '[:lower:]')
TAGS="kind=worker,os=macos,java=8,os-version=${OS_VERSION},xcode-version=${XCODE_VERSION},machine-type=${MACHINE_TYPE}"
sed -i '' "s/^tags=.*/tags=${TAGS}/" /usr/local/etc/buildkite-agent/buildkite-agent.cfg
echo "Set tags to $(cat /usr/local/etc/buildkite-agent/buildkite-agent.cfg | grep '^tags=')"
sudo -H -u buildkite env \
GOOGLE_APPLICATION_CREDENTIALS=/usr/local/etc/buildkite-agent/bazel-public-e29b1f995cb1.json \
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
/usr/local/bin/buildkite-agent start \
--config /usr/local/etc/buildkite-agent/buildkite-agent.cfg
killall -9 -u buildkite
find /private/tmp -user buildkite -delete
find /private/var/tmp -user buildkite -delete
/usr/local/bin/rsync -aAX --delete /Users/buildkite-fresh/ /Users/buildkite/