-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updates builder to use common stuff like email and monitoring * Don't hardcode instance names for singletons (probably problematic if/when we restart * Latest images
- Loading branch information
1 parent
d90f329
commit b419a94
Showing
19 changed files
with
157 additions
and
148 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
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
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MAILTO=compiler-explorer-admin@googlegroups.com | ||
PATH=/home/ubuntu/infra/.env/bin:/home/ubuntu/infra/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
|
||
# m h dom mon dow command |
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 |
---|---|---|
|
@@ -17,4 +17,6 @@ for img_file in "${IMG_DIR}"/**/*.img; do | |
fi | ||
done | ||
|
||
echo -n "Waiting for mounts to complete..." | ||
wait | ||
echo "done" |
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
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
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
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
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,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
set -exuo pipefail | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
cd "${DIR}" | ||
|
@@ -14,7 +14,7 @@ fi | |
|
||
env EXTRA_NFS_ARGS="" "${DIR}/setup-common.sh" | ||
|
||
apt -y install mosh fish jq ssmtp cronic subversion upx gdb autojump zlib1g-dev m4 python3 python3-venv python3.8 python3.8-venv libc6-dev-i386 | ||
apt -y install mosh fish jq cronic subversion upx gdb autojump zlib1g-dev m4 python3 python3-venv python3.8 python3.8-venv libc6-dev-i386 | ||
chsh ubuntu -s /usr/bin/fish | ||
|
||
cd /home/ubuntu/infra | ||
|
@@ -33,28 +33,10 @@ chown -R ubuntu:ubuntu /home/ubuntu/infra | |
sudo -u ubuntu fish setup.fish | ||
crontab -u ubuntu crontab.admin | ||
|
||
# Configure email | ||
SMTP_PASS=$(aws ssm get-parameter --name /admin/smtp_pass | jq -r .Parameter.Value) | ||
cat >/etc/ssmtp/ssmtp.conf <<EOF | ||
root=postmaster | ||
mailhub=email-smtp.us-east-1.amazonaws.com | ||
hostname=compiler-explorer.com | ||
FromLineOverride=NO | ||
AuthUser=AKIAJZWPG4D3SSK45LJA | ||
AuthPass=${SMTP_PASS} | ||
UseTLS=YES | ||
UseSTARTTLS=YES | ||
EOF | ||
cat >/etc/ssmtp/revaliases <<EOF | ||
ubuntu:[email protected]:email-smtp.us-east-1.amazonaws.com | ||
EOF | ||
|
||
chfn -f 'Compiler Explorer Admin' ubuntu | ||
chmod 640 /etc/ssmtp/* | ||
|
||
echo admin-node >/etc/hostname | ||
hostname admin-node | ||
sed -i "/127.0.0.1/c 127.0.0.1 localhost admin-node" /etc/hosts | ||
sed -i "/preserve_hostname/c preserve_hostname: true" /etc/cloud/cloud.cfg | ||
|
||
if ! grep vm.min_free_kbytes /etc/sysctl.conf; then | ||
echo "vm.min_free_kbytes=65536" >>/etc/sysctl.conf | ||
|
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
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,58 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
set -exuo pipefail | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
if [[ "$1" != "--updated" ]]; then | ||
sudo -u ubuntu git -C "${DIR}" pull | ||
pwd | ||
exec bash "${BASH_SOURCE[0]}" --updated | ||
exit 0 | ||
fi | ||
|
||
if [[ ! -f /updated.2 ]]; then | ||
wget -qO- https://get.docker.com/ | sh | ||
touch /updated.2 | ||
fi | ||
|
||
env EXTRA_NFS_ARGS="" "${DIR}/setup-common.sh" | ||
|
||
apt -y install python2.7 mosh fish jq ssmtp cronic subversion upx gdb | ||
chsh ubuntu -s /usr/bin/fish | ||
wget -qO- https://get.docker.com/ | sh | ||
usermod -aG docker ubuntu | ||
|
||
cd /home/ubuntu/infra | ||
pip install --upgrade -r requirements.txt | ||
apt -y install mosh fish cronic subversion upx gdb | ||
chsh ubuntu -s /usr/bin/fish | ||
|
||
# Install private and public keys | ||
aws ssm get-parameter --name /admin/ce_private_key | jq -r .Parameter.Value >/home/ubuntu/.ssh/id_rsa | ||
|
||
chmod 600 /home/ubuntu/.ssh/id_rsa | ||
aws s3 cp s3://compiler-explorer/authorized_keys/admin.key /home/ubuntu/.ssh/id_rsa.pub | ||
chown -R ubuntu:ubuntu /home/ubuntu/.ssh | ||
chown -R ubuntu:ubuntu /home/ubuntu/infra | ||
|
||
sudo -u ubuntu fish setup.fish | ||
crontab -u ubuntu crontab.builder | ||
|
||
echo builder >/etc/hostname | ||
hostname builder | ||
sed -i "/127.0.0.1/c 127.0.0.1 localhost builder" /etc/hosts | ||
sed -i "/preserve_hostname/c preserve_hostname: true" /etc/cloud/cloud.cfg | ||
|
||
mv /infra /home/ubuntu/infra | ||
chown -R ubuntu:ubuntu /home/ubuntu/infra | ||
sudo -u ubuntu make -C /home/ubuntu/infra ce | ||
|
||
# Configure email | ||
SMTP_PASS=$(aws ssm get-parameter --name /admin/smtp_pass | jq -r .Parameter.Value) | ||
cat >/etc/ssmtp/ssmtp.conf <<EOF | ||
root=postmaster | ||
mailhub=email-smtp.us-east-1.amazonaws.com | ||
hostname=compiler-explorer.com | ||
FromLineOverride=NO | ||
AuthUser=AKIAJZWPG4D3SSK45LJA | ||
AuthPass=${SMTP_PASS} | ||
UseTLS=YES | ||
UseSTARTTLS=YES | ||
EOF | ||
cat >/etc/ssmtp/revaliases <<EOF | ||
ubuntu:[email protected]:email-smtp.us-east-1.amazonaws.com | ||
EOF | ||
|
||
chfn -f 'Compiler Explorer Admin' ubuntu | ||
chmod 640 /etc/ssmtp/* | ||
|
||
echo builder-node > /etc/hostname | ||
hostname builder-node | ||
sed -i "/127.0.0.1/c 127.0.0.1 localhost builder-node" /etc/hosts | ||
ln -s /efs/squash-images /opt/squash-images |
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,15 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
set -exuo pipefail | ||
|
||
# https://askubuntu.com/questions/132059/how-to-make-a-package-manager-wait-if-another-instance-of-apt-is-running | ||
wait_for_apt() { | ||
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do | ||
echo "Waiting for other software managers to finish..." | ||
sleep 5 | ||
done | ||
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do | ||
echo "Waiting for other software managers to finish..." | ||
sleep 5 | ||
done | ||
} | ||
|
||
# Sometimes it seems auto apt takes a while to kick in... | ||
|
@@ -20,19 +18,31 @@ wait_for_apt | |
|
||
apt-get -y update | ||
apt-get -y upgrade --force-yes | ||
apt-get -y install unzip libwww-perl libdatetime-perl nfs-common jq python3-pip wget cachefilesd qemu-user-static libc6-arm64-cross libtinfo5 | ||
apt-get -y install \ | ||
jq \ | ||
libc6-arm64-cross \ | ||
libdatetime-perl \ | ||
libtinfo5 \ | ||
libwww-perl \ | ||
nfs-common \ | ||
python3-pip \ | ||
python3-venv \ | ||
qemu-user-static \ | ||
ssmtp \ | ||
unzip \ | ||
wget | ||
|
||
apt-get -y autoremove | ||
pip3 install --upgrade pip | ||
hash -r pip | ||
pip install --upgrade awscli | ||
touch /updated | ||
|
||
mkdir -p /root/.aws /home/ubuntu/.aws | ||
echo -e "[default]\nregion=us-east-1" | tee /root/.aws/config /home/ubuntu/.aws/config | ||
chown -R ubuntu /home/ubuntu/.aws | ||
|
||
get_conf() { | ||
aws ssm get-parameter --name $1 | jq -r .Parameter.Value | ||
aws ssm get-parameter --name "$1" | jq -r .Parameter.Value | ||
} | ||
|
||
LOG_DEST_HOST=$(get_conf /compiler-explorer/logDestHost) | ||
|
@@ -97,9 +107,28 @@ chmod 600 /etc/grafana/agent.yaml.tpl | |
|
||
mkdir -p /efs | ||
if ! grep "/efs nfs" /etc/fstab; then | ||
echo "fs-db4c8192.efs.us-east-1.amazonaws.com:/ /efs nfs nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport${EXTRA_NFS_ARGS} 0 0" >>/etc/fstab | ||
echo "fs-db4c8192.efs.us-east-1.amazonaws.com:/ /efs nfs nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport${EXTRA_NFS_ARGS} 0 0" >>/etc/fstab | ||
fi | ||
|
||
# Configure email | ||
SMTP_PASS=$(aws ssm get-parameter --name /admin/smtp_pass | jq -r .Parameter.Value) | ||
cat >/etc/ssmtp/ssmtp.conf <<EOF | ||
root=postmaster | ||
mailhub=email-smtp.us-east-1.amazonaws.com | ||
hostname=compiler-explorer.com | ||
FromLineOverride=NO | ||
AuthUser=AKIAJZWPG4D3SSK45LJA | ||
AuthPass=${SMTP_PASS} | ||
UseTLS=YES | ||
UseSTARTTLS=YES | ||
EOF | ||
cat >/etc/ssmtp/revaliases <<EOF | ||
ubuntu:[email protected]:email-smtp.us-east-1.amazonaws.com | ||
EOF | ||
|
||
chfn -f 'Compiler Explorer Admin' ubuntu | ||
chmod 640 /etc/ssmtp/* | ||
|
||
mount -a | ||
|
||
cd /home/ubuntu/ | ||
|
Oops, something went wrong.