-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_data.sh
59 lines (52 loc) · 1.44 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
#!/bin/bash
# Debugging data
echo "Running in ${pwd}"
# Update DNS record
HOSTED_ZONE_ID='Z04348901LY77KHP2FYDP'
RECORD_NAME='nosy-cat.tk'
PUBLIC_IP=`curl http://169.254.169.254/latest/meta-data/public-ipv4`
FILENAME='change.json'
echo "
{
\"Comment\": \"Upsert $RECORD_NAME ip\",
\"Changes\": [
{
\"Action\": \"UPSERT\",
\"ResourceRecordSet\": {
\"Name\": \"$RECORD_NAME\",
\"Type\": \"A\",
\"TTL\": 60,
\"ResourceRecords\": [
{
\"Value\": \"$PUBLIC_IP\"
}
]
}
}
]
}
" > $FILENAME
aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file://$FILENAME
# Install Docker
yum update -y
amazon-linux-extras install docker
service docker start
usermod -a -G docker ec2-user
# Install Docker-Compose
curl -L "https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod 0555 /usr/local/bin/docker-compose
export PATH=$PATH:/local/bin
echo 'export PATH=$PATH:/local/bin' >> /home/ec2-user/.bashrc
# Customizations :)
echo 'alias docc=docker-compose' >> /home/ec2-user/.bashrc
# Install Git & Clone Repo
yum install git -y
cd /home/ec2-user
git clone https://github.com/toblich/nosy-cat.git
# Start everything
chown -R ec2-user nosy-cat
cd nosy-cat/
docker-compose up --no-start
docker-compose up -d neo4j influxdb kafka redis
sleep 300
docker-compose up -d