-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser-data.sh
99 lines (78 loc) · 2.78 KB
/
user-data.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
echo "Debug: Environment variables"
env
echo "Debug: AWS credentials"
aws sts get-caller-identity
# Install and configure NTP
yum update -y
yum install -y chrony
systemctl enable chronyd
systemctl start chronyd
# Configure chrony for high precision
cat > /etc/chrony.conf << EOF
makestep 1 3
rtcsync
local stratum 10
allow
EOF
# Restart chrony with new config
systemctl restart chronyd
# Wait for chrony to sync
sleep 5
# Install Docker
yum install -y docker
systemctl start docker
systemctl enable docker
# Add ec2-user to docker group
usermod -a -G docker ec2-user
# Debug: Check Docker status
echo "Debug: Docker status"
systemctl status docker
# Debug: Check Docker installation
echo "Debug: Docker version"
docker --version
echo "Debug: Testing ECR access"
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 971228983574.dkr.ecr.eu-central-1.amazonaws.com
echo "Debug: Container type - {container_type}"
# check if container type is replica, then run a replica
if [ "{container_type}" == "replica" ]; then
echo "Debug: Pulling replica image"
docker pull 971228983574.dkr.ecr.eu-central-1.amazonaws.com/mini-pod-replica:latest
echo "Debug: Running replica container"
docker run -d \
-e SCHNORR_SECRET_KEY="{secret_key}" \
-e TZ=UTC \
-p 8080:8080 \
-p 8081:8081 \
971228983574.dkr.ecr.eu-central-1.amazonaws.com/mini-pod-replica:latest
fi
if [ "{container_type}" == "reading-client" ]; then
echo "Debug: Pulling reading-client image"
docker pull 971228983574.dkr.ecr.eu-central-1.amazonaws.com/mini-pod-reading-client:latest
mkdir -p /home/ec2-user/experiment-data
chown ec2-user:ec2-user /home/ec2-user/experiment-data
echo "Debug: Running reading-client container"
docker run -d \
-e REPLICA_IPS="{replica_ips}" \
-e REPLICA_KEYS="{replica_keys}" \
-e TZ=UTC \
-v /home/ec2-user/experiment-data:/experiment-data \
--cap-add SYS_TIME \
--cap-add SYS_NICE \
971228983574.dkr.ecr.eu-central-1.amazonaws.com/mini-pod-reading-client:latest
fi
if [ "{container_type}" == "writing-client" ]; then
echo "Debug: Pulling writing-client image"
docker pull 971228983574.dkr.ecr.eu-central-1.amazonaws.com/mini-pod-writing-client:latest
mkdir -p /home/ec2-user/experiment-data
chown ec2-user:ec2-user /home/ec2-user/experiment-data
echo "Debug: Running writing-client container"
docker run -d \
-e REPLICA_IPS="{replica_ips}" \
-e NUM_EXPERIMENTS="{num_experiments}" \
-e TZ=UTC \
-v /home/ec2-user/experiment-data:/experiment-data \
--cap-add SYS_TIME \
--cap-add SYS_NICE \
971228983574.dkr.ecr.eu-central-1.amazonaws.com/mini-pod-writing-client:latest
fi