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 | |
| 8 | mkdir -p $BOT_DIR |
| 9 | |
| 10 | #curl "https://repo.stackdriver.com/stack-install.sh" | bash -s -- --write-gcm |
| 11 | |
| 12 | apt-get update -y |
| 13 | apt-get upgrade -y |
| 14 | |
Eric Fiselier | 4e903a3 | 2018-12-15 03:24:33 +0000 | [diff] [blame] | 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! |
Eric Fiselier | 8c03322 | 2019-01-19 09:07:04 +0000 | [diff] [blame^] | 18 | apt-get install lld-9 |
Eric Fiselier | 4e903a3 | 2018-12-15 03:24:33 +0000 | [diff] [blame] | 19 | rm /usr/bin/ld |
Eric Fiselier | 8c03322 | 2019-01-19 09:07:04 +0000 | [diff] [blame^] | 20 | ln -s /usr/bin/lld-9 /usr/bin/ld |
Eric Fiselier | 4e903a3 | 2018-12-15 03:24:33 +0000 | [diff] [blame] | 21 | |
Eric Fiselier | 9c97ca1 | 2018-11-19 18:43:31 +0000 | [diff] [blame] | 22 | systemctl set-property buildslave.service TasksMax=100000 |
| 23 | |
| 24 | buildslave stop $BOT_DIR |
| 25 | |
| 26 | chown buildbot:buildbot $BOT_DIR |
| 27 | |
| 28 | echo "Connecting as $BOT_NAME" |
| 29 | buildslave create-slave --allow-shutdown=signal $BOT_DIR lab.llvm.org:9990 $BOT_NAME $BOT_PASS |
| 30 | |
| 31 | echo "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 | |
| 42 | echo "SLAVE_RUNNER=/usr/bin/buildslave |
| 43 | SLAVE_ENABLED[1]=\"1\" |
| 44 | SLAVE_NAME[1]=\"buildslave1\" |
| 45 | SLAVE_USER[1]=\"buildbot\" |
| 46 | SLAVE_BASEDIR[1]=\"$BOT_DIR\" |
| 47 | SLAVE_OPTIONS[1]=\"\" |
| 48 | SLAVE_PREFIXCMD[1]=\"\"" > /etc/default/buildslave |
| 49 | |
| 50 | chown -R buildbot:buildbot $BOT_DIR |
| 51 | systemctl daemon-reload |
| 52 | service buildslave restart |
| 53 | |
| 54 | sleep 30 |
| 55 | cat $BOT_DIR/twistd.log |
| 56 | grep "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. |
| 60 | sleep 72000 |
| 61 | while pkill -SIGHUP buildslave; do sleep 5; done; |
Eric Fiselier | 8c03322 | 2019-01-19 09:07:04 +0000 | [diff] [blame^] | 62 | shutdown now |