blob: c135fc4af89e40dc37360c2fef8171f8871ae699 [file] [log] [blame]
Eric Fiselier9c97ca12018-11-19 18:43:31 +00001#!/usr/bin/env bash
2set -x
3
4BOT_DIR=/b
5BOT_NAME=$1
6BOT_PASS=$2
7
Eric Fiselierb0f10132019-01-19 23:36:06 +00008pushd /tmp
9curl -sSO https://dl.google.com/cloudagents/install-monitoring-agent.sh
10bash install-monitoring-agent.sh
11curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
12bash install-logging-agent.sh --structured
13popd
Eric Fiselier9c97ca12018-11-19 18:43:31 +000014
Eric Fiselierb0f10132019-01-19 23:36:06 +000015mkdir -p $BOT_DIR
Eric Fiselier9c97ca12018-11-19 18:43:31 +000016
17apt-get update -y
18apt-get upgrade -y
19
Eric Fiselier4e903a32018-12-15 03:24:33 +000020# 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 Fiselier8c033222019-01-19 09:07:04 +000023apt-get install lld-9
Eric Fiselier4e903a32018-12-15 03:24:33 +000024rm /usr/bin/ld
Eric Fiselier8c033222019-01-19 09:07:04 +000025ln -s /usr/bin/lld-9 /usr/bin/ld
Eric Fiselier4e903a32018-12-15 03:24:33 +000026
Eric Fiselier9c97ca12018-11-19 18:43:31 +000027systemctl set-property buildslave.service TasksMax=100000
28
29buildslave stop $BOT_DIR
30
31chown buildbot:buildbot $BOT_DIR
32
33echo "Connecting as $BOT_NAME"
34buildslave create-slave --allow-shutdown=signal $BOT_DIR lab.llvm.org:9990 $BOT_NAME $BOT_PASS
35
36echo "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
47echo "SLAVE_RUNNER=/usr/bin/buildslave
48SLAVE_ENABLED[1]=\"1\"
49SLAVE_NAME[1]=\"buildslave1\"
50SLAVE_USER[1]=\"buildbot\"
51SLAVE_BASEDIR[1]=\"$BOT_DIR\"
52SLAVE_OPTIONS[1]=\"\"
53SLAVE_PREFIXCMD[1]=\"\"" > /etc/default/buildslave
54
55chown -R buildbot:buildbot $BOT_DIR
56systemctl daemon-reload
57service buildslave restart
58
59sleep 30
60cat $BOT_DIR/twistd.log
61grep "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.
65sleep 72000
66while pkill -SIGHUP buildslave; do sleep 5; done;
Eric Fiselier8c033222019-01-19 09:07:04 +000067shutdown now