2019-02-13 19:18:47 +00:00
|
|
|
#! /bin/bash -e
|
|
|
|
# Provision an AWS cloud instance with tutor.
|
2019-03-10 16:10:52 +00:00
|
|
|
# Run with: curl -sSL https://raw.githubusercontent.com/regisb/tutor/master/cloud/aws.sh | sudo bash -e
|
2019-02-13 19:18:47 +00:00
|
|
|
|
2019-02-14 07:59:07 +00:00
|
|
|
export TUTOR_USER="$SUDO_USER"
|
2019-02-13 19:18:47 +00:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
echo "=============== Installing system dependencies"
|
|
|
|
apt update \
|
|
|
|
&& apt upgrade -y \
|
|
|
|
&& apt install -y \
|
|
|
|
apt-transport-https \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
gnupg-agent \
|
|
|
|
software-properties-common \
|
|
|
|
supervisor
|
|
|
|
|
|
|
|
echo "=============== Installing docker"
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
|
|
|
add-apt-repository \
|
|
|
|
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
|
|
|
$(lsb_release -cs) \
|
|
|
|
stable"
|
|
|
|
apt update
|
|
|
|
apt install -y docker-ce docker-ce-cli containerd.io
|
|
|
|
docker run hello-world
|
2019-02-14 07:59:07 +00:00
|
|
|
usermod -aG docker $TUTOR_USER
|
2019-02-13 19:18:47 +00:00
|
|
|
|
|
|
|
echo "=============== Installing docker-compose"
|
|
|
|
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
|
|
chmod +x /usr/local/bin/docker-compose
|
|
|
|
|
|
|
|
echo "=============== Installing tutor"
|
2019-02-18 08:42:44 +00:00
|
|
|
curl -L "https://github.com/regisb/tutor/releases/download/latest/tutor-$(uname -s)_$(uname -m)" -o /usr/local/bin/tutor
|
2019-02-13 19:18:47 +00:00
|
|
|
chmod +x /usr/local/bin/tutor
|
|
|
|
|
2019-03-06 15:32:23 +00:00
|
|
|
echo "=============== Building docker images"
|
|
|
|
tutor images env
|
|
|
|
tutor images build all
|
|
|
|
|
2019-03-10 16:10:52 +00:00
|
|
|
echo "=============== Configure Web UI login/password"
|
|
|
|
tutor webui configure --user tutor --password "$(curl http://169.254.169.254/latest/meta-data/public-hostname)"
|
|
|
|
|
2019-02-13 19:18:47 +00:00
|
|
|
echo "=============== Configuring supervisor"
|
|
|
|
echo "[program:tutor]
|
|
|
|
command=/usr/local/bin/tutor webui start
|
2019-02-14 07:59:07 +00:00
|
|
|
environment=HOME=/home/$TUTOR_USER
|
2019-02-13 19:18:47 +00:00
|
|
|
autorestart=true
|
2019-02-14 07:59:07 +00:00
|
|
|
user=$TUTOR_USER" > /etc/supervisor/conf.d/tutor.conf
|
2019-02-13 19:18:47 +00:00
|
|
|
supervisorctl update
|