-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·143 lines (119 loc) · 2.89 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·143 lines (119 loc) · 2.89 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
#!/bin/bash
declare -r pyexe=python3
declare -r pymanage="$pyexe manage.py"
declare -r custom_docker_settings="/exodus/exodus/exodus/settings/custom_docker.py"
declare -Ar commandList=(
[collect-static]=collectStatic
[compile-messages]=compileMessages
[create-db]=createDB
[create-user]=createUser
[import-trackers]=importTrackers
[init]=init
[make-messages]=makeMessages
[refresh-fdroid-index]=refreshFdroidIndex
[start-frontend]=startFrontEnd
[start-worker]=startWorker
[test]=test
)
declare -Ar commandHelpList=(
[collect-static]='collect all static files'
[compile-messages]='compile translation messages'
[create-db]='create database if required and attend to migrations'
[create-user]='actually create a super user if not created yet'
[import-trackers]='import trackers from the official exodus instance'
[init]='Initialize database and launch Exodus'
[make-messages]='extract translation messages'
[refresh-fdroid-index]='fetch F-Droids list of packages'
[start-frontend]='lauch the local front end'
[start-worker]='start the exodus worker'
[test]='run tests'
)
function main()
{
getSettings
if [ -z "$1" ]
then
usage "$0"
elif [ -n "${commandList[$1]}" ]
then
"${commandList[$1]}"
else
exec "$@"
fi
}
function usage()
{
cat <<- EOS
$1: prepare and lauch exodus
EOS
for cmd in "${!commandHelpList[@]}"
do
cat <<- EOS
$cmd: ${commandHelpList[$cmd]}
EOS
done
}
function getSettings() {
if [ -f "$custom_docker_settings" ]; then
export DJANGO_SETTINGS_MODULE=exodus.settings.custom_docker
else
export DJANGO_SETTINGS_MODULE=exodus.settings.docker
cat <<- EOS
File ${custom_docker_settings} doesn't exist, you might want to create it:
from .docker import *
DEBUG=True
GOOGLE_ACCOUNT_USERNAME = "<a valid google account>"
GOOGLE_ACCOUNT_PASSWORD = "<a valid google password>"
SECRET_KEY = "<a unique secret for Django>"
EOS
fi
}
function createDB() {
echo 'CREATE EXTENSION IF NOT EXISTS pg_trgm;' | $pymanage dbshell
$pymanage makemigrations
$pymanage migrate
}
function createUser() {
$pymanage createsuperuser
}
function startWorker() {
export C_FORCE_ROOT=1
exec celery -A exodus.core worker --beat -l info -S django
}
function collectStatic() {
$pymanage collectstatic --noinput
}
function startFrontend() {
exec $pymanage runserver 0.0.0.0:8000
}
function importTrackers() {
$pymanage import_categories
$pymanage importtrackers
}
function makeMessages() {
$pymanage makemessages
}
function compileMessages() {
$pymanage compilemessages
}
function refreshFdroidIndex() {
$pymanage refresh_fdroid_index
}
function test() {
$pymanage test
}
function init_db() {
while ! pg_isready -h db -U exodus -p 5432 > /dev/null 2> /dev/null; do
echo "Connecting to db (postgresql) Failed: Waiting ..."
sleep 1
done
createDB
importTrackers
echo "Exodus DB is ready."
}
function init() {
init_db
compileMessages
startFrontend
}
main "$@"