This repository was archived by the owner on Sep 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_site.sh
More file actions
executable file
·191 lines (165 loc) · 6.11 KB
/
run_site.sh
File metadata and controls
executable file
·191 lines (165 loc) · 6.11 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
set -e
echo -e "\n[y/N] indicates a yes/no question. the default is the letter in CAPS. If answer is not understood, will revert to default\n"
if [ "${1}" == "--env_file" ];
then
export run_through_setup="y";
read_from_env_file="true";
. ./CI/set_env.sh
if [[ "${basic_config__DOCKERIZED}" == "y" ]];
then
export basic_config__DOCKERIZED='1'
else
export basic_config__DOCKERIZED='0'
fi
if [[ "${database_config__postgresSQL}" == "1" ]];
then
export dockerized_database='y'
export sqlite3_database='n'
else
export dockerized_database='n'
export sqlite3_database='y'
fi
else
echo "Do you need to run through the setup? [y/N]"
read run_through_setup
fi
if [ "${run_through_setup}" == "y" ];
then
if [ -z "${basic_config__TOKEN}" ];
then
echo "What is your discord bot's token? [see https://discord.com/developers/docs/getting-started if you are not sure how to get it]"
read basic_config__TOKEN
fi
if [ -z "${basic_config__GUILD_ID}" ];
then
echo "What is your discord guild's ID? [see https://discord.com/developers/docs/game-sdk/store and https://github.com/CSSS/wall_e/blob/master/documentation/Working_on_Bot/pictures/get_guild_id.png to see where to get it]"
read basic_config__GUILD_ID
fi
use_defaults="false";
if [ "${1}" == "--default" ];
then
use_defaults="true";
sqlite3_database="y";
launch_wall_e="y";
dockerized_database="n";
fi
if [ -z "${basic_config__DOCKERIZED}" ];
then
echo "Do you want to use a dockerized wall_e? [y/N] a dockerized wall_e is harder to debug but you might run into OS compatibility issues with some of the python modules"
read basic_config__DOCKERIZED
if [[ "${basic_config__DOCKERIZED}" == "y" ]];
then
export basic_config__DOCKERIZED='1'
else
expport basic_config__DOCKERIZED='0'
fi
fi
if [[ "$OSTYPE" == "linux-gnu"* ]];
then
supported_os="true"
else
supported_os="false"
fi
if [ "${use_defaults}" != "true" ];
then
echo "Do you you want this script to launch wall_e? [Yn] [the alternative is to use PyCharm]"
read launch_wall_e
fi
echo 'basic_config__TOKEN='"'"${basic_config__TOKEN}"'" > CI/wall_e_api.env
echo 'basic_config__ENVIRONMENT='"'"'LOCALHOST'"'" >> CI/wall_e_api.env
echo 'basic_config__COMPOSE_PROJECT_NAME='"'"'discord_bot'"'" >> CI/wall_e_api.env
echo 'basic_config__GUILD_ID='"'"${basic_config__GUILD_ID}"'" >> CI/wall_e_api.env
if [[ "${basic_config__DOCKERIZED}" == "y" ]];
then
if [[ "${supported_os}" == "false" ]];
then
echo "sorry, script is not currently setup to use anything other than a dockerized posgtres database on non-linux system :-("
echo "Please feel free to add that feature in"
exit 1
fi
echo -e 'basic_config__DOCKERIZED='"'1'\n\n" >> CI/wall_e_api.env
else
echo -e 'basic_config__DOCKERIZED='"'0'\n\n" >> CI/wall_e_api.env
fi
export POSTGRES_PASSWORD='postgres_passwd'
echo 'database_config__WALL_E_DB_DBNAME='"'"'csss_discord_db'"'" >> CI/wall_e_api.env
echo 'database_config__WALL_E_DB_USER='"'"'wall_e'"'" >> CI/wall_e_api.env
echo 'database_config__WALL_E_DB_PASSWORD='"'"'wallEPassword'"'" >> CI/wall_e_api.env
echo 'database_config__ENABLED='"'"'1'"'" >> CI/wall_e_api.env
if [[ "${basic_config__DOCKERIZED}" == "y" ]];
then
export COMPOSE_PROJECT_NAME="discord_bot"
echo 'database_config__postgresSQL='"'"'1'"'" >> CI/wall_e_api.env
echo -e 'database_config__HOST='"'"${COMPOSE_PROJECT_NAME}_wall_e_db"'\n\n" >> CI/wall_e_api.env
echo 'ORIGIN_IMAGE='"'"'sfucsssorg/wall_e'"'" >> CI/wall_e_api.env
echo 'POSTGRES_PASSWORD='"'"${POSTGRES_PASSWORD}"'" >> CI/wall_e_api.env
cd wall_e
. ../CI/user_scripts/set_env.sh
../CI/user_scripts/setup-dev-env.sh
docker logs -f "${COMPOSE_PROJECT_NAME}_wall_e"
else
if [[ "${use_defaults}" != "true" && -z "${sqlite3_database}" ]];
then
echo "Do you want to use db.sqlite3 for the database? [alternative is a separate service, dockerized or not] [Y/n]"
read sqlite3_database
fi
if [[ "${sqlite3_database}" != "y" && -z "${dockerized_database}" ]];
then
echo "Do you intended to use dockerized postgres? [Y/n]"
read dockerized_database
fi
if [[ "${dockerized_database}" == "y" && "${supported_os}" == "false" ]];
then
echo "sorry, script is not currently setup to use anything other than a dockerized posgtres database on non-linux system :-("
echo "Please feel free to add that feature in"
exit 1
fi
if [ "${sqlite3_database}" != "y" ];
then
echo 'database_config__postgresSQL='"'"'1'"'" >> CI/wall_e_api.env
echo 'database_config__HOST='"'"'127.0.0.1'"'" >> CI/wall_e_api.env
echo 'database_config__DB_PORT='"'"'5432'"'" >> CI/wall_e_api.env
else
echo 'database_config__postgresSQL='"'"'0'"'" >> CI/wall_e_api.env
echo 'database_config__HOST='"'"'discord_bot_wall_e_db'"'" >> CI/wall_e_api.env
fi
cd wall_e_leveling_api
python3 -m pip install -r requirements.txt
. ../CI/set_env.sh
if [[ "${sqlite3_database}" == "y" ]];
then
rm ../db.sqlite3 || true
else
sudo apt-get install postgresql-contrib
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/create-database.ddl
fi
python3 manage.py migrate
rm wall_e.json* || true
wget https://dev.sfucsss.org/wall_e/fixtures/wall_e.json
python3 manage.py loaddata wall_e.json
rm wall_e.json* || true
if [ "${launch_wall_e}" == "n" ];
then
echo -e "\n\nSeems you are going to use something else to launch the bot. If you are going to use PyCharm, I HIGHLY recommend using https://github.com/ashald/EnvFile"
fi
fi
else
launch_wall_e="y"
fi
if [ "${launch_wall_e}" != "n" ];
then
echo "Launching the website."
sleep 3
python3 manage.py runserver 127.0.0.1:8000
fi