-
Notifications
You must be signed in to change notification settings - Fork 19
/
run_walle.sh
executable file
·90 lines (79 loc) · 3.42 KB
/
run_walle.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
85
86
87
88
89
90
#!/bin/bash
set -e -o xtrace
# https://stackoverflow.com/a/5750463/7734535
if [ -z "${VIRTUAL_ENV}" ]; then
echo "please active a python virtual environment before using this script"
exit 1
fi
# need to delete and re-create so that the if statement that tries to detected if the
# help menu was invoked can work correctly
if [ -f "CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env" ]; then
cat ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env | grep -v HELP_SELECTED > ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env.2
mv ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env.2 ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env
fi
./.run_walle.py $@
while [ "$#" -gt 0 ]
do
shift
done
. ./CI/validate_and_deploy/2_deploy/user_scripts/set_env.sh
. ./CI/validate_and_deploy/2_deploy/user_scripts/set_env.sh run_wall_e.env
if [ -z "${HELP_SELECTED}" ]; then
exit 0
fi
if [[ "${basic_config__DOCKERIZED}" == "1" ]]; then
export COMPOSE_PROJECT_NAME="${basic_config__COMPOSE_PROJECT_NAME}"
./CI/validate_and_deploy/2_deploy/user_scripts/setup-dev-env.sh
docker logs -f "${COMPOSE_PROJECT_NAME}_wall_e"
else
pushd wall_e
if [[ "${INSTALL_REQUIREMENTS}" == "True" ]]; then
rm layer-1-requirements.txt layer-2-requirements.txt || true
wget https://raw.githubusercontent.com/CSSS/wall_e_python_base/master/layer-1-requirements.txt
wget https://raw.githubusercontent.com/CSSS/wall_e_python_base/master/layer-2-requirements.txt
python3 -m pip install -r layer-1-requirements.txt
python3 -m pip install -r layer-2-requirements.txt
rm layer-1-requirements.txt layer-2-requirements.txt
python3 -m pip install -r requirements.txt
python3 -m pip install -r ../.wall_e_models/requirements.txt
fi
if [[ "${SETUP_DATABASE}" == "True" ]]; then
if [[ "${database_config__TYPE}" == "sqlite3" ]]; then
rm ../db.sqlite3 || true
else
dpkg -s postgresql-client &> /dev/null
if [[ $? -eq 1 ]];
then
sudo apt-get install postgresql-client
fi
docker rm -f "${basic_config__COMPOSE_PROJECT_NAME}_wall_e_db"
sleep 4
docker run -d --env POSTGRES_PASSWORD=${POSTGRES_PASSWORD} -p \
"${database_config__DB_PORT}":5432 --name "${basic_config__COMPOSE_PROJECT_NAME}_wall_e_db" \
postgres:alpine
sleep 4
PGPASSWORD=$POSTGRES_PASSWORD psql --set=WALL_E_DB_USER="${database_config__WALL_E_DB_USER}" \
--set=WALL_E_DB_PASSWORD="${database_config__WALL_E_DB_PASSWORD}" \
--set=WALL_E_DB_DBNAME="${database_config__WALL_E_DB_DBNAME}" \
-h "${database_config__HOST}" -p "${database_config__DB_PORT}" -U "postgres" \
-f ../CI/validate_and_deploy/2_deploy/create-database.ddl
fi
python3 django_manage.py migrate
rm banrecords.json commandstats.json levels.json profilebucketsinprogress.json reminders.json userpoints.json || true
wget -r --no-parent -nd https://dev.sfucsss.org/wall_e/fixtures/ -A 'json'
python3 django_manage.py loaddata banrecords.json
python3 django_manage.py loaddata commandstats.json
python3 django_manage.py loaddata levels.json
python3 django_manage.py loaddata profilebucketsinprogress.json
python3 django_manage.py loaddata reminders.json
python3 django_manage.py loaddata userpoints.json
rm banrecords.json commandstats.json levels.json profilebucketsinprogress.json reminders.json userpoints.json || true
fi
popd
fi
if [[ "${LAUNCH_WALL_E}" == "True" ]]; then
echo "Launching the wall_e."
sleep 3
cd wall_e
python3 main.py
fi