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