This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1559777 - incorporated feedback from @milescrabill
- Loading branch information
Showing
2 changed files
with
68 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,66 @@ | ||
#!/bin/bash | ||
mkdir -p /home/ubuntu/generic-worker | ||
cd /home/ubuntu/generic-worker | ||
apt update | ||
apt upgrade -y | ||
apt install -y apt-transport-https ca-certificates curl software-properties-common | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
|
||
set -exv | ||
exec &> /var/log/userdata.log | ||
|
||
# Version numbers #################### | ||
GENERIC_WORKER_VERSION='v15.1.2' | ||
LIVELOG_VERSION='v1.1.0' | ||
TASKCLUSTER_PROXY_VERSION='v5.1.0' | ||
###################################### | ||
|
||
function retry { | ||
set +e | ||
local n=0 | ||
local max=3 | ||
while true; do | ||
"$@" && break || { | ||
if [[ $n -lt $max ]]; then | ||
((n++)) | ||
echo "Command failed. Attempt $n/$max:" >&2 | ||
else | ||
echo "Failed after $n attempts." >&2 | ||
exit 1 | ||
fi | ||
} | ||
done | ||
set -e | ||
} | ||
|
||
start_time="$(date '+%s')" | ||
|
||
# install docker | ||
retry apt update | ||
retry apt upgrade -y | ||
retry apt install -y apt-transport-https ca-certificates curl software-properties-common | ||
retry curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" | ||
apt update | ||
retry apt update | ||
apt-cache policy docker-ce | grep -qF download.docker.com | ||
apt install -y docker-ce | ||
retry apt install -y docker-ce | ||
sleep 5 | ||
systemctl status docker | grep "Started Docker Application Container Engine" | ||
usermod -aG docker ubuntu | ||
id -nG | grep docker | ||
curl -L https://github.com/taskcluster/generic-worker/releases/download/v15.1.2/generic-worker-simple-linux-amd64 > generic-worker | ||
curl -L https://github.com/taskcluster/taskcluster-proxy/releases/download/v5.1.0/taskcluster-proxy-linux-amd64 > taskcluster-proxy | ||
curl -L https://github.com/taskcluster/livelog/releases/download/v1.1.0/livelog-linux-amd64 > livelog | ||
|
||
# install generic-worker into /home/ubuntu/generic-worker | ||
mkdir -p /home/ubuntu/generic-worker | ||
cd /home/ubuntu/generic-worker | ||
retry curl -L "https://github.com/taskcluster/generic-worker/releases/download/${GENERIC_WORKER_VERSION}/generic-worker-simple-linux-amd64" > generic-worker | ||
retry curl -L "https://github.com/taskcluster/livelog/releases/download/${LIVELOG_VERSION}/livelog-linux-amd64" > livelog | ||
retry curl -L "https://github.com/taskcluster/taskcluster-proxy/releases/download/${TASKCLUSTER_PROXY_VERSION}/taskcluster-proxy-linux-amd64" > taskcluster-proxy | ||
chmod a+x generic-worker taskcluster-proxy livelog | ||
chown -R ubuntu:ubuntu /home/ubuntu/generic-worker | ||
./generic-worker --version | ||
./generic-worker new-ed25519-keypair --file ed25519.key | ||
|
||
# ensure host 'taskcluster' resolves to localhost | ||
echo 127.0.1.1 taskcluster >> /etc/hosts | ||
|
||
# configure generic-worker to run on boot | ||
echo '@reboot PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /home/ubuntu/generic-worker/generic-worker run --configure-for-aws --config /home/ubuntu/generic-worker/generic-worker.config >> /home/ubuntu/generic-worker/generic-worker.log 2>&1' | crontab -u ubuntu - | ||
# apt install -y gnome | ||
# sed -i 's/.*#.* \(AutomaticLoginEnable = true\)/\1/' | ||
# sed -i 's/.*#.* AutomaticLogin =.*/AutomaticLogin = ubuntu/' | ||
# mkdir -p .config/autostart | ||
# echo IyBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiMgTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwojIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uCltEZXNrdG9wIEVudHJ5XQpUeXBlPUFwcGxpY2F0aW9uCkV4ZWM9Z25vbWUtdGVybWluYWwgLXggL2hvbWUvdWJ1bnR1L2dlbmVyaWMtd29ya2VyIHJ1biAtLWNvbmZpZyAvaG9tZS91YnVudHUvZ2VuZXJpYy13b3JrZXIuY29uZmlnIC0tY29uZmlndXJlLWZvci1hd3MgPiAvaG9tZS91YnVudHUvZ2VuZXJpYy13b3JrZXIubG9nIDI+JjEKSGlkZGVuPWZhbHNlClgtR05PTUUtQXV0b3N0YXJ0LWVuYWJsZWQ9dHJ1ZQpOYW1lPUdlbmVyaWMtV29ya2VyCkNvbW1lbnQ9U3RhcnQgZ2VuZXJpYy13b3JrZXIgaW4gYSB0ZXJtaW5hbCBzZXNzaW9uClN0YXJ0dXBOb3RpZnk9ZmFsc2UKVGVybWluYWw9ZmFsc2UKVHlwZT1BcHBsaWNhdGlvbgo= | base64 -d > .config/autostart/gnome-terminal.desktop | ||
# apt install -y xrdp | ||
# passwd ubuntu | ||
|
||
end_time="$(date '+%s')" | ||
echo "UserData execution took: $(($end_time-$start_time)) seconds" | ||
|
||
# shutdown so that instance can be snapshotted | ||
shutdown now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters