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 | |
| 15 | systemctl set-property buildslave.service TasksMax=100000 |
| 16 | |
| 17 | buildslave stop $BOT_DIR |
| 18 | |
| 19 | chown buildbot:buildbot $BOT_DIR |
| 20 | |
| 21 | echo "Connecting as $BOT_NAME" |
| 22 | buildslave create-slave --allow-shutdown=signal $BOT_DIR lab.llvm.org:9990 $BOT_NAME $BOT_PASS |
| 23 | |
| 24 | echo "Eric Fiselier <ericwf@google.com>" > $BOT_DIR/info/admin |
| 25 | |
| 26 | { |
| 27 | uname -a | head -n1 |
| 28 | cmake --version | head -n1 |
| 29 | g++ --version | head -n1 |
| 30 | ld --version | head -n1 |
| 31 | date |
| 32 | lscpu |
| 33 | } > $BOT_DIR/info/host |
| 34 | |
| 35 | echo "SLAVE_RUNNER=/usr/bin/buildslave |
| 36 | SLAVE_ENABLED[1]=\"1\" |
| 37 | SLAVE_NAME[1]=\"buildslave1\" |
| 38 | SLAVE_USER[1]=\"buildbot\" |
| 39 | SLAVE_BASEDIR[1]=\"$BOT_DIR\" |
| 40 | SLAVE_OPTIONS[1]=\"\" |
| 41 | SLAVE_PREFIXCMD[1]=\"\"" > /etc/default/buildslave |
| 42 | |
| 43 | chown -R buildbot:buildbot $BOT_DIR |
| 44 | systemctl daemon-reload |
| 45 | service buildslave restart |
| 46 | |
| 47 | sleep 30 |
| 48 | cat $BOT_DIR/twistd.log |
| 49 | grep "slave is ready" $BOT_DIR/twistd.log || shutdown now |
| 50 | |
| 51 | # GCE can restart instance after 24h in the middle of the build. |
| 52 | # Gracefully restart before that happen. |
| 53 | sleep 72000 |
| 54 | while pkill -SIGHUP buildslave; do sleep 5; done; |
| 55 | shutdown now |