-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·96 lines (70 loc) · 2.54 KB
/
install.sh
File metadata and controls
executable file
·96 lines (70 loc) · 2.54 KB
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
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# This setup script has been tested under Ubuntu 18.04 LTS Server
# The active user must be a member of the sudo and docker groups
export cwd="$(pwd)"
# Setup directories and permissions
sudo mkdir /data
sudo chgrp -R etag /data
sudo chmod -R 775 /data
mkdir /data/postgres
#TODO: confirm and add missing required directories
sudo chgrp -R etag /opt
sudo chmod -R 775 /opt
# Fetch cybercommons and apply ETAG defaults
cd /opt
cookiecutter https://github.com/cybercommons/cybercom-cookiecutter --config-file "$cwd/config.yml" --no-input
# Apply custom configuration patches
cd "$cwd"
patch -b /opt/etag/config/api_config.py -i api_config.patch
patch -b /opt/etag/config/celery/code/celeryconfig.py -i celeryconfig.patch
patch -b /opt/etag/config/celery/code/requirements.txt -i celeryrequirements.patch
patch -b /opt/etag/run/cybercom_up -i cybercom_up.patch
# Get ETAG API
rm -rf /opt/etag/api_code
git clone https://github.com/etag/etag-api /opt/etag/api_code
cd /opt/etag/api_code
docker build -t api .
# Initialize Postgres DB
# Clone ETAG schema
git clone https://github.com/etag/etag_schema /opt/etag/etag_schema
docker run -d --name=etag_postgres \
-e POSTGRES_PASSWORD=etag_master \
-v /data/postgres:/var/lib/postgresql/data \
postgres:11
echo "Sleeping for 10 seconds to give Postgres a chance to startup..."
sleep 10
# Create databases and access
docker cp "$cwd/config.sql" etag_postgres:/tmp/config.sql
docker exec -it etag_postgres psql \
-U postgres \
-d postgres \
-f /tmp/config.sql
# Load ETAG specific schema
docker cp /opt/etag/etag_schema/etag_schema_script.sql etag_postgres:/tmp/etag_schema_script.sql
docker exec -it etag_postgres psql \
-U postgres \
-d postgres \
-f /tmp/etag_schema_script.sql
docker stop etag_postgres
docker rm etag_postgres
#FIXME: need to run django migrations
#docker run -it --rm \
# --link etag_postgres:cybercom_postgres \
#echo "********* API *********************"
#docker run -d --name etag_api \
# --link etag_memcache:cybercom_memcache \
# --link etag_mongo:cybercom_mongo \
# --link etag_rabbitmq:cybercom_rabbitmq \
# --link etag_postgres:cybercom_postgres \
# -p 8080:8080 \
# -v /opt/etag/config/ssl/backend:/ssl:z \
# -v /opt/etag/api_code:/usr/src/app:z \
# -v /opt/etag/config/api_config.py:/usr/src/app/api/config.py:z \
# -v /opt/etag/config/db.sqlite3:/usr/src/app/db.sqlite3:z \
# -v /opt/etag/log:/log:z \
# -v /opt/etag/data:/data:z \
# api
#TODO: clone portal, build, and deploy to static directory
# Startup cyberCommons / ETAG
cd /opt/etag
./run/cybercom_up