forked from compiler-explorer/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-builder-startup.sh
executable file
·48 lines (37 loc) · 1011 Bytes
/
setup-builder-startup.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
#!/bin/bash
# called on every startup
set -euo pipefail
systemctl stop docker
umount /ephemeral || true
# swap was 57GB (!) hopefully we really don't need that much
SWAP_SIZE=$((8 * 1024 * 1024 * 1024 / 512))
sfdisk /dev/nvme1n1 <<EOF
,${SWAP_SIZE},82
;
EOF
sync
sleep 2 # let the device get registered
mkswap /dev/nvme1n1p1
swapon /dev/nvme1n1p1
mkfs.ext4 -F /dev/nvme1n1p2
rm -rf /ephemeral
mkdir /ephemeral
mount /dev/nvme1n1p2 /ephemeral
cat >/etc/docker/daemon.json <<EOF
{
"data-root": "/ephemeral/docker"
}
EOF
mount_opt() {
mkdir -p /opt/compiler-explorer
mountpoint /opt/compiler-explorer || mount --bind /efs/compiler-explorer /opt/compiler-explorer
mkdir -p /opt/intel
mountpoint /opt/intel || mount --bind /efs/intel /opt/intel
mkdir -p /opt/arm
mountpoint /opt/arm || mount --bind /efs/arm /opt/arm
[ -f /opt/.health ] || touch /opt/.health
mountpoint /opt/.health || mount --bind /efs/.health /opt/.health
./mount-all-img.sh
}
mount_opt
systemctl start docker