blob: 5cdebe86a830c9c459c552f131d7df90e334eb82 [file]
#!/bin/bash
#
# Script to setup a host for running in Home Swarming CI.
#
# Prereqs:
# this script and its dependencies are scp'd to the swarm lab host via:
# $ scp /google/data/ro/teams/cast-test/swarming/* gtvchrome@<lab-host-ip>:/home/gtvchrome/
# (gtvchrome password in valentine)
# all of these shell scripts have chmod +x on the lab host: chmod +x *.sh
# you're ssh'd into the lab host and ready to run this script on it
#
# Usage:
# ./setup_swarm_host.sh
# stop any bots that might be running already
for abspath in /etc/init/swarming*.conf; do
filename=$(basename "$abspath")
botname="${filename%.*}"
sudo stop "$botname"
done
# our puppet config requires at least 1 bot dir set up already
echo -e "Visit the following URL to get the latest token code and copy-paste it below.\n"
echo -e "https://cast-swarming.appspot.com\n"
read -p "Token Code: " token
SWARM_HOME=~/swarm_home
if [ ! -d "$SWARM_HOME" ]; then
mkdir $SWARM_HOME
fi
cd $SWARM_HOME
rm -rf bots ; mkdir -p bots/1 ; cd bots/1
curl -sSLOJ https://cast-swarming.appspot.com/bot_code?tok=$token
# Fetch a temporary copy of our puppet configs from cipd and run it.
# The puppet config will set up a permanent puppet config dir and keep it up-to-date with cron.
source $HOME/install_cipd.sh $HOME/depot_tools/
# Init masterless puppet config only on gtvchrome lab hosts.
# Ganeti hosts are configured via ENC puppet (mosaic-role user, not gtvchrome)
if [[ "$PWD" =~ gtvchrome ]]; then
rm -rf /tmp/puppet; mkdir /tmp/puppet; cd /tmp/puppet
cipd install home_internal/swarm_puppet staging -service-account-json ~/luci/swarming-key.json
sudo apt-get install --yes puppet
sudo /usr/bin/puppet apply --modulepath ./ ./cast_builder/files/swarm/lab_nodes/site.pp
fi