This repository was archived by the owner on Jun 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlauncher
More file actions
executable file
·199 lines (175 loc) · 4.87 KB
/
launcher
File metadata and controls
executable file
·199 lines (175 loc) · 4.87 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
192
193
194
195
196
197
198
199
#!/bin/bash
usage () {
echo "Usage: ${0} COMMAND CONFIG [--skip-prereqs] [--docker-args STRING]"
echo "Commands:"
echo " env: Create a Python virtual environment"
echo " install: Installs developer environment"
echo " test: Run tests with coverage"
echo " run: Runs Django webserver"
echo " start: Runs the Django webserver"
echo " migrate: Runs the Django migrations"
echo " celery: Runs celery worker and beat"
echo " flower: Runs celery flower"
echo " shell: Runs the django shell"
echo " build: Builds the Docker images"
echo " docs: Builds and serves docs"
}
command=$1
if [ -z "$command" ]; then
usage
exit 1
fi
run_env() {
python3 -m venv myvenv
}
run_build() {
docker build -t kryptedgaming/krypted .
}
run_install() {
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
export INSTALLED_APPS=accounts,group_requests,applications
echo "Installing the Krypted Platform developer environment"
if [ ! -d "./app" ]; then
echo "Please run in the root project directory"
exit 1
fi
command=$1
if [ -n "$command" ]; then
case "$command" in
*)
usage
exit 1
;;
esac
fi
# Install python requirements
echo "Installing Python Requirements"
pip3 install -r requirements.txt > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to install Python requirements"
exit 1
fi
echo "Installing Python Development Requirements"
pip3 install coverage pytest pytest-cov python-coveralls sphinx-markdown-tables django-extensions ipython notebook > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to install Python Development requirements"
exit 1
fi
# Install Developer Settings
cp ./conf/settings.py.example ./app/app/settings.py
# Set up the Django project
echo "Setting up the Django Project"
echo "Creating migrations for project"
python3 ./app/manage.py makemigrations > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to set up the Django project"
exit 1
fi
echo "Creating migrations for specific subprojects"
python3 ./app/manage.py makemigrations accounts > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to set up the Django project"
exit 1
fi
echo "Creating database for project"
python3 ./app/manage.py migrate > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to set up the Django project"
exit 1
fi
# Create STATIC directory
mkdir -p ./app/app/static
mkdir -p ./app/accounts/static
# Install AdminLTE UI
echo "Installing AdminLTE in app/static/adminlte/"
wget -q https://github.com/ColorlibHQ/AdminLTE/archive/v3.0.5.tar.gz
tar -xvf v3.0.5.tar.gz -C ./app/app/static/ > /dev/null
mv ./app/app/static/AdminLTE-3.0.5 ./app/app/static/adminlte
rm v3.0.5.tar.gz*
# Install AccountStylingV2
echo "Installing Accounts Styling in app/static/accounts"
wget -q https://github.com/KryptedGaming/krypted/releases/download/v4.0.0/Accounts_v12.tar.gz
tar -xvf Accounts_v12.tar.gz -C ./app/accounts/static/ > /dev/null
rm Accounts_v12.tar.gz*
# Collect static
python3 ./app/manage.py collectstatic --noinput > /dev/null
# Create cache table
python3 ./app/manage.py createcachetable > /dev/null
echo "${green}INSTALL COMPLETE. Add django_extensions to your DJANGO_APPS in settings.py${reset}"
}
run_test() {
coverage run --omit=**/tests/**.py,**/tests.py,./install/*,./launcher,**/wsgi.py,**/manage.py --source=./app/. ./app/manage.py test $1 --noinput --settings=app.settings
coverage xml
coverage html
}
run_server() {
cd ./app/
python3 manage.py runserver
}
run_shell() {
cd ./app/
python3 manage.py shell_plus
}
run_migrate() {
cd ./app/
python3 manage.py makemigrations
python3 manage.py migrate
cd ..
}
run_celery() {
cd ./app/
celery -A app worker --beat --scheduler django_celery_beat.schedulers:DatabaseScheduler --loglevel=debug
}
run_celery_flower() {
cd ./app/
celery flower -A app --address=127.0.0.1 --port=5555
}
case "$command" in
env)
run_env
echo "Virtual Environment created"
exit 0
;;
install)
run_install
exit 0
;;
build)
run_build
exit 0
;;
test)
run_test $2
exit 0
;;
run)
run_server
exit 0
;;
start)
run_server
exit 0
;;
celery)
run_celery
exit 0
;;
flower)
run_celery_flower
exit 0
;;
shell)
run_shell
exit 0
;;
migrate)
run_migrate
exit 0
;;
*)
usage
exit 1
;;
esac