-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.sh
84 lines (64 loc) · 2.55 KB
/
install.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -e
# Export poetry requirements to scripts/requirements.txt
poetry export -f requirements.txt --output scripts/requirements.txt --without-hashes
# Run the terraform script to create the resources
cd tf || exit
# shellcheck disable=SC1091
terraform init && \
terraform plan -out tf.plan && \
terraform apply tf.plan
GENERATED_IP=$(terraform output -raw ip_address)
export GENERATED_IP
cd ..
# Use sed to replace the sqlite password in the .env file
SQLITE_KEY_GENERATED=$(openssl rand -base64 28)
export SQLITE_KEY_GENERATED
export DOMAIN="pintura.cloud" # Example DOMAIN name
export DOMAIN_PYTHON_SAFE="pintura-cloud" # Example DOMAIN, no periods or spaces
export USER="${DOMAIN_PYTHON_SAFE}"
echo "User: ${USER}"
echo "Domain: ${DOMAIN}"
echo "Domain_python_safe: ${DOMAIN_PYTHON_SAFE}"
. envsubst < .env.template > .env
cat .env
./setenv.sh .env
cp .env scripts/.env
# Push the install script to the instance
# Copy all the files from ./website directory to
# /var/www/pintura using rsync
rsync -avz -e "ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null" --rsync-path="sudo rsync" \
scripts/ ubuntu@"${IP}":/gunicorn
# Run the install script on the remote machine
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
ubuntu@"${IP}" \
"sudo bash /gunicorn/install_nginx.sh"
# Run the install script on the remote machine
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
ubuntu@"${IP}" \
"sudo bash /gunicorn/install_bacalhau.sh 2&1> /dev/null"
# Install the downloader
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
ubuntu@"${IP}" \
"sudo bash /gunicorn/install_bacalhau_downloader.sh"
# Install the downloader
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
ubuntu@"${IP}" \
"sudo bash /gunicorn/install_bacalhau_image_creator.sh"
# Split out into its own file so we can update independantly
./update_website.sh
# Restart all services just to be sure
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
ubuntu@"${IP}" \
"sudo bash /gunicorn/restart_all_services.sh"
# Make all .sh files in the /gunicorn readable only by root
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
ubuntu@"${IP}" \
"sudo chmod 700 /gunicorn/*.sh"