1#!/usr/bin/env bash 2set -x 3 4BOT_DIR=/b 5BOT_NAME=$1 6BOT_PASS=$2 7 8mkdir -p $BOT_DIR 9 10#curl "https://repo.stackdriver.com/stack-install.sh" | bash -s -- --write-gcm 11 12apt-get update -y 13apt-get upgrade -y 14 15# FIXME(EricWF): Remove this hack. It's only in place to temporarily fix linking libclang_rt from the 16# debian packages. 17# WARNING: If you're not a buildbot, DO NOT RUN! 18apt-get install lld-8 19rm /usr/bin/ld 20ln -s /usr/bin/lld-8 /usr/bin/ld 21 22systemctl set-property buildslave.service TasksMax=100000 23 24buildslave stop $BOT_DIR 25 26chown buildbot:buildbot $BOT_DIR 27 28echo "Connecting as $BOT_NAME" 29buildslave create-slave --allow-shutdown=signal $BOT_DIR lab.llvm.org:9990 $BOT_NAME $BOT_PASS 30 31echo "Eric Fiselier <ericwf@google.com>" > $BOT_DIR/info/admin 32 33{ 34 uname -a | head -n1 35 cmake --version | head -n1 36 g++ --version | head -n1 37 ld --version | head -n1 38 date 39 lscpu 40} > $BOT_DIR/info/host 41 42echo "SLAVE_RUNNER=/usr/bin/buildslave 43SLAVE_ENABLED[1]=\"1\" 44SLAVE_NAME[1]=\"buildslave1\" 45SLAVE_USER[1]=\"buildbot\" 46SLAVE_BASEDIR[1]=\"$BOT_DIR\" 47SLAVE_OPTIONS[1]=\"\" 48SLAVE_PREFIXCMD[1]=\"\"" > /etc/default/buildslave 49 50chown -R buildbot:buildbot $BOT_DIR 51systemctl daemon-reload 52service buildslave restart 53 54sleep 30 55cat $BOT_DIR/twistd.log 56grep "slave is ready" $BOT_DIR/twistd.log || shutdown now 57 58# GCE can restart instance after 24h in the middle of the build. 59# Gracefully restart before that happen. 60sleep 72000 61while pkill -SIGHUP buildslave; do sleep 5; done; 62shutdown now