2019-11-01 17:44:30 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# reminder: logs from userdata script go to /var/log/cloud-init-output.log
|
|
|
|
# you can also log script output by adding this to the top of the script:
|
|
|
|
# exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
|
|
|
|
# see https://aws.amazon.com/premiumsupport/knowledge-center/ec2-linux-log-user-data/
|
|
|
|
|
2019-11-07 20:06:10 +01:00
|
|
|
sudo apt update && \
|
|
|
|
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common unzip awscli && \
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
|
|
|
|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
|
|
|
|
sudo apt install -y docker-ce docker-ce-cli containerd.io && \
|
|
|
|
sudo systemctl enable docker && sudo systemctl start docker && \
|
|
|
|
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
|
|
|
|
sudo chmod +x /usr/local/bin/docker-compose
|
2019-11-01 17:44:30 +01:00
|
|
|
|
2019-11-07 20:06:10 +01:00
|
|
|
wget -O /home/ubuntu/snapshot.sh "https://raw.githubusercontent.com/lbryio/snapshots/master/snapshot.sh"
|
|
|
|
wget -O /home/ubuntu/docker-compose.yml "https://gist.githubusercontent.com/lyoshenka/2557c08344bfe1020f0c0a13b9c5b0ce/raw/docker-compose.yml"
|
2019-11-01 17:44:30 +01:00
|
|
|
|
2019-11-07 20:06:10 +01:00
|
|
|
chown ubuntu:ubuntu /home/ubuntu/snapshot.sh /home/ubuntu/docker-compose.yml
|
|
|
|
chmod +x /home/ubuntu/snapshot.sh
|
2019-11-01 17:44:30 +01:00
|
|
|
|
|
|
|
sudo --set-home --non-interactive --user=ubuntu /bin/bash -c 'cd /home/ubuntu; ./snapshot.sh'
|