forked from compiler-explorer/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-admin.sh
executable file
·57 lines (45 loc) · 1.54 KB
/
setup-admin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -ex
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${DIR}
if [[ "$1" != "--updated" ]]; then
sudo -u ubuntu git -C ${DIR} pull
pwd
exec bash ${BASH_SOURCE[0]} --updated
exit 0
fi
env EXTRA_NFS_ARGS="" ${DIR}/setup-common.sh
apt -y install python2.7 python-pip mosh fish jq ssmtp cronic subversion upx gdb autojump zlib1g-dev m4
chsh ubuntu -s /usr/bin/fish
cd /home/ubuntu/compiler-explorer-image
pip install --upgrade pip
hash -r pip
pip install --upgrade awscli
pip install -r requirements.txt
# 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/compiler-explorer-image
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/*
hostname admin-node
perl -pi -e 's/127.0.0.1 localhost/127.0.0.1 localhost admin-node/' /etc/hosts