2019-02-13 19:18:47 +00:00
|
|
|
#! /bin/bash -e
|
|
|
|
# Provision an AWS cloud instance with tutor.
|
2019-03-10 17:13:02 +00:00
|
|
|
# Run with: curl -sSL https://raw.githubusercontent.com/regisb/tutor/master/cloud/aws.sh | bash -e
|
2019-02-13 19:18:47 +00:00
|
|
|
|
2019-03-10 17:13:02 +00:00
|
|
|
export TUTOR_USER="$USER"
|
2019-02-13 19:18:47 +00:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
echo "=============== Installing system dependencies"
|
2019-03-10 17:13:02 +00:00
|
|
|
sudo apt update \
|
|
|
|
&& sudo apt install -y \
|
2019-02-13 19:18:47 +00:00
|
|
|
apt-transport-https \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
gnupg-agent \
|
2019-03-11 17:47:33 +00:00
|
|
|
software-properties-common
|
2019-02-13 19:18:47 +00:00
|
|
|
|
|
|
|
echo "=============== Installing docker"
|
2019-03-10 17:13:02 +00:00
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
|
|
sudo add-apt-repository \
|
2019-02-13 19:18:47 +00:00
|
|
|
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
|
|
|
$(lsb_release -cs) \
|
|
|
|
stable"
|
2019-03-10 17:13:02 +00:00
|
|
|
sudo apt update
|
|
|
|
sudo apt install -y docker-ce docker-ce-cli containerd.io
|
|
|
|
sudo usermod -aG docker $TUTOR_USER
|
2019-02-13 19:18:47 +00:00
|
|
|
docker run hello-world
|
|
|
|
|
|
|
|
echo "=============== Installing docker-compose"
|
2019-03-10 17:13:02 +00:00
|
|
|
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
|
|
sudo chmod +x /usr/local/bin/docker-compose
|
2019-02-13 19:18:47 +00:00
|
|
|
|
|
|
|
echo "=============== Installing tutor"
|
2019-03-10 17:13:02 +00:00
|
|
|
sudo curl -L "https://github.com/regisb/tutor/releases/download/latest/tutor-$(uname -s)_$(uname -m)" -o /usr/local/bin/tutor
|
|
|
|
sudo chmod +x /usr/local/bin/tutor
|
2019-02-13 19:18:47 +00:00
|
|
|
|
2019-03-06 15:32:23 +00:00
|
|
|
echo "=============== Building docker images"
|
|
|
|
tutor images env
|
|
|
|
tutor images build all
|
|
|
|
|
2019-03-10 17:53:28 +00:00
|
|
|
echo "=============== Create Web UI script"
|
|
|
|
echo '#! /bin/bash
|
|
|
|
if [ ! -f $(tutor config printroot)/env/webui/config.yml ]; then
|
2019-03-11 17:25:24 +00:00
|
|
|
mkdir -p $(tutor config printroot)/env/webui
|
2019-03-10 17:53:28 +00:00
|
|
|
tutor webui configure --user tutor --password "$(curl http://169.254.169.254/latest/meta-data/instance-id)"
|
|
|
|
fi
|
|
|
|
tutor webui start' | sudo tee /usr/local/bin/tutor-webui
|
|
|
|
sudo chmod +x /usr/local/bin/tutor-webui
|
2019-03-10 16:10:52 +00:00
|
|
|
|
2019-03-11 17:47:33 +00:00
|
|
|
echo "=============== Configuring systemd"
|
|
|
|
echo "[Unit]
|
|
|
|
Description=Tutor web UI
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
User=$TUTOR_USER
|
|
|
|
WorkingDirectory=/home/$TUTOR_USER
|
|
|
|
Environment="HOME=/home/$TUTOR_USER"
|
|
|
|
ExecStart=/usr/local/bin/tutor-webui
|
|
|
|
Restart=on-failure
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/tutor-webui.service
|
|
|
|
sudo systemctl enable tutor-webui
|