forked from wri/carbon-budget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2_launch_template_startup_instructions.TXT
61 lines (48 loc) · 1.98 KB
/
ec2_launch_template_startup_instructions.TXT
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
#!/bin/bash
yum install -y rsync git nano htop tmux
#######################################
# Mount the ephemeral storage
#######################################
mkfs.ext4 /dev/nvme1n1
mkdir -p /mnt/ext
mount -t ext4 /dev/nvme1n1 /mnt/ext
# make temp directory for containers usage
# should be used in the Batch job definition (MountPoints)
mkdir /mnt/ext/tmp
rsync -avPHSX /tmp/ /mnt/ext/tmp/
mkdir -p /var/lib/docker
mkdir -p /mnt/ext/docker
# modify fstab to mount /tmp on the new storage.
sed -i '$ a /mnt/ext/tmp /tmp none bind 0 0' /etc/fstab
sed -i '$ a /mnt/ext/docker /var/lib/docker none bind 0 0' /etc/fstab
mount -a
# make /tmp usable by everyone
chmod 777 /mnt/ext/tmp
#######################################
# Install docker and docker-compose, per https://acloudxpert.com/how-to-install-docker-compose-on-amazon-linux-ami/
#######################################
yum install -y docker
curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
#############################
# Copy latest flux model repo to the home folder
#############################
cd /home/ec2-user
git clone https://github.com/wri/carbon-budget
cd carbon-budget
cd /home/ec2-user/carbon-budget/
#######################################
# Starts the docker service
#######################################
sudo service docker start
######################################
# Gives the user (ec2-user) various permissions, such as ability to git pull.
#Based on https://techoverflow.net/2019/05/07/how-to-fix-git-error-cannot-open-git-fetch_head-permission-denied/
######################################
cd /
sudo chown -R ec2-user: .
# Replaces htop config file with my preferred configuration
mkdir -p /home/ec2-user/.config/htop/
cp /home/ec2-user/carbon-budget/htoprc /home/ec2-user/.config/htop/htoprc