This repository has been archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
341 lines (256 loc) · 9.86 KB
/
Makefile
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
PRJ_DIR := prj/ntg/ntg
ROOT := $(UNI_DIR)/$(PRJ_DIR)
NTG_HOST := ntg.uni-muenster.de
NTG_USER := ntg
NTG := $(NTG_USER)@$(NTG_HOST)
NTG_PRJ := $(NTG):/home/$(NTG_USER)/prj/ntg/ntg
NTG_SERVER := $(NTG_PRJ)/server
NTG_CLIENT := $(NTG):/var/www/ntg
RSYNC := /usr/bin/rsync -azv --exclude '*~'
SHELL := /bin/bash
PYTHON := /usr/bin/python3
MYSQL := mysql --defaults-file=~/.my.cnf.ntg
BROWSER := firefox
JSDOC := jsdoc -c doc_src/jsdoc.conf.js
RSYNCPY := $(RSYNC) --exclude "**/__pycache__" --exclude "*.pyc"
PSQL_PORT := 5432
PSQL := psql -p $(PSQL_PORT)
PGDUMP := pg_dump -p $(PSQL_PORT)
SERVER := server
CLIENT := client
SCRIPTS := scripts
DOCS := docs
JS_SRC := $(wildcard $(CLIENT)/src/js/*.js)
VUE_SRC := $(wildcard $(CLIENT)/src/components/*.vue $(CLIENT)/src/components/widgets/*.vue)
PY_SOURCES := scripts/cceh/*.py ntg_common/*.py
.PHONY: client server upload vpn psql
.PHONY: lint pylint eslint csslint
.PHONY: docs jsdoc sphinxdoc
client:
cd client; make build; cd ..
client-production:
cd client; make build-production; cd ..
client-clean:
cd client; make clean; cd ..
dev-server:
cd client; make dev-server; cd ..
cd server; make server; cd ..
dev-server-production:
cd client; make dev-server-production; cd ..
cd server; make server; cd ..
server:
export PYTHONPATH=$(ROOT)/server:$(ROOT); \
python3 -m server -vvv
common-clean:
cd ntg_common ; make clean; cd ..
server-clean:
cd server ; make clean; cd ..
docker-build: server-clean common-clean client-production
cd docker; make build; cd ..
docker-run:
cd docker; make run; cd ..
docker-push:
cd docker; make push; cd ..
users:
scripts/cceh/mk_users.py -vvv instance/_global.conf
psql_on_remote:
psql -h $(NTG_HOST) -U $(NTG_USER) -d ntg_user
clean: client-clean
find . -depth -name "*~" -delete
# sudo -u postgres psql
#
# CREATE USER ntg CREATEDB PASSWORD '<password>';
# CREATE DATABASE ntg_user OWNER ntg;
#
# CREATE DATABASE acts_ph4 OWNER ntg;
#
# \c acts_ph4
# CREATE SCHEMA ntg AUTHORIZATION ntg;
# ALTER DATABASE acts_ph4 SET search_path = ntg, public;
# CREATE EXTENSION mysql_fdw;
# GRANT USAGE ON FOREIGN DATA WRAPPER mysql_fdw TO ntg;
#
# GRANT CONNECT ON DATABASE acts_ph4 TO ntg_readonly;
# GRANT USAGE ON SCHEMA ntg TO ntg_readonly;
# GRANT SELECT ON ALL TABLES IN SCHEMA ntg TO ntg_readonly;
# \q
import_acts:
-$(MYSQL) -e "DROP DATABASE ECM_ActsPh4"
$(MYSQL) -e "CREATE DATABASE ECM_ActsPh4"
cat ../dumps/ECM_ActsPh4_Final_20170712.dump | $(MYSQL) -D ECM_ActsPh4
-$(MYSQL) -e "DROP DATABASE VarGenAtt_ActPh4"
$(MYSQL) -e "CREATE DATABASE VarGenAtt_ActPh4"
cat ../dumps/VarGenAtt_ActPh3_20170712.dump | $(MYSQL) -D VarGenAtt_ActPh4
python3 -m scripts.cceh.import -vvv instance/acts_ph4.conf
import_cl:
-$(MYSQL) -e "DROP DATABASE ECM_CL_Ph2"
$(MYSQL) -e "CREATE DATABASE ECM_CL_Ph2"
cat ../dumps/CL_export_vollstaendig.dump | $(MYSQL) -D ECM_CL_Ph2
-$(MYSQL) -e "DROP DATABASE VG_CL_Ph2"
$(MYSQL) -e "CREATE DATABASE VG_CL_Ph2"
cat ../dumps/ECM_KB_2.dump | $(MYSQL) -D VG_CL_Ph2
python3 -m scripts.cceh.import -vvv instance/cl_ph2.conf
import_john_ph1:
-$(MYSQL) -e "DROP DATABASE DCPJohnWithFam"
$(MYSQL) -e "CREATE DATABASE DCPJohnWithFam"
zcat ../dumps/DCPJohnWithFam-9.sql | $(MYSQL) -D DCPJohnWithFam
python3 -m scripts.cceh.import -vvv instance/john_ph1.conf
import_john_f1_ph1:
-$(MYSQL) -e "DROP DATABASE DCPJohnFamily1"
$(MYSQL) -e "CREATE DATABASE DCPJohnFamily1"
cat ../dumps/DCPJohnFamily1.sql | $(MYSQL) -D DCPJohnFamily1
python3 -m scripts.cceh.import -vvv instance/john_f1_ph1.conf
import_mark_ph1:
-$(MYSQL) -e "DROP DATABASE ECM_Mark_Ph12"
$(MYSQL) -e "CREATE DATABASE ECM_Mark_Ph12"
cat ../dumps/ECM_Mk_CBGM_Milestone2.dump | $(MYSQL) -D ECM_Mark_Ph12
python3 -m scripts.cceh.import -vvv instance/mark_ph12.conf
import_mark_ph2:
-$(MYSQL) -e "DROP DATABASE ECM_Mark_Ph2"
$(MYSQL) -e "CREATE DATABASE ECM_Mark_Ph2"
cat ../dumps/ECM_Mk_Apparat_6.dump | $(MYSQL) -D ECM_Mark_Ph2
python3 -m scripts.cceh.import -vvv instance/mark_ph2.conf
import_mark_ph22:
-$(MYSQL) -e "DROP DATABASE ECM_Mark_Ph2"
$(MYSQL) -e "CREATE DATABASE ECM_Mark_Ph2"
bzcat ../dumps/ECM_Mk_Apparat_6.dump.bz2 | $(MYSQL) -D ECM_Mark_Ph2
python3 -m scripts.cceh.import -vvv instance/mark_ph22.conf
import_mark_ph3: import_nestle
-$(MYSQL) -e "DROP DATABASE ECM_Mark_Ph3"
$(MYSQL) -e "CREATE DATABASE ECM_Mark_Ph3"
bzcat ../dumps/ECM_Mark_20200810.dump.bz2 | $(MYSQL) -D ECM_Mark_Ph3
python3 -m scripts.cceh.import -vvv instance/mark_ph3.conf
import_nestle:
-$(MYSQL) -e "DROP DATABASE Nestle29"
$(MYSQL) -e "CREATE DATABASE Nestle29"
bzcat ../dumps/Nestle29-4.dump.bz2 | $(MYSQL) -D Nestle29
import_2sam:
-$(MYSQL) -e "DROP DATABASE 2Sam_Ph21"
$(MYSQL) -e "CREATE DATABASE 2Sam_Ph21"
bzcat ../dumps/2Sam_apparat_20200628.dump.bz2 | $(MYSQL) -D 2Sam_Ph21
-$(MYSQL) -e "DROP DATABASE LXX_Leitzeile"
$(MYSQL) -e "CREATE DATABASE LXX_Leitzeile"
bzcat ../dumps/LXX.dump.bz2 | $(MYSQL) -D LXX_Leitzeile
python3 -m scripts.cceh.import -vvv instance/2sam_ph21.conf
acts_ph4:
python3 -m scripts.cceh.prepare -vvv instance/acts_ph4.conf
python3 -m scripts.cceh.cbgm -vvv instance/acts_ph4.conf
acts_ph5:
$(PSQL) -d template1 -c "DROP DATABASE IF EXISTS acts_ph5"
$(PSQL) -d template1 -c "CREATE DATABASE acts_ph5 WITH TEMPLATE acts_ph4 OWNER ntg"
python3 -m scripts.cceh.cbgm -vvv instance/acts_ph5.conf
cl:
python3 -m scripts.cceh.prepare -vvv instance/cl_ph2.conf
python3 -m scripts.cceh.cbgm -vvv instance/cl_ph2.conf
john:
python3 -m scripts.cceh.prepare -vvv instance/john_ph1.conf
python3 -m scripts.cceh.cbgm -vvv instance/john_ph1.conf
john_f1:
python3 -m scripts.cceh.prepare -vvv instance/john_f1_ph1.conf
python3 -m scripts.cceh.cbgm -vvv instance/john_f1_ph1.conf
mark_ph1:
python3 -m scripts.cceh.prepare -vvv instance/mark_ph12.conf
python3 -m scripts.cceh.cbgm -vvv instance/mark_ph12.conf
mark_ph2:
python3 -m scripts.cceh.prepare -vvv instance/mark_ph2.conf
python3 -m scripts.cceh.cbgm -vvv instance/mark_ph2.conf
mark_ph22:
python3 -m scripts.cceh.prepare -vvv instance/mark_ph22.conf
python3 -m scripts.cceh.cbgm -vvv instance/mark_ph22.conf
mark_ph3:
python3 -m scripts.cceh.prepare -vvv instance/mark_ph3.conf
python3 -m scripts.cceh.cbgm -vvv instance/mark_ph3.conf
2sam_ph21:
python3 -m scripts.cceh.prepare -vvv instance/2sam_ph21.conf
python3 -m scripts.cceh.cbgm -vvv instance/2sam_ph21.conf
DBS := acts_ph3 acts_ph4 acts_ph5 john_ph1 john_f1_ph1 mark_ph1 mark_ph12 mark_ph2 mark_ph22 cl_ph2 2sam_ph21
#################
define TEMPLATE =
upload_dbs_from_work: upload_$(1)_from_work
upload_dbs_from_home: upload_$(1)_from_home
# from work (fast connection, pipe to psql on the host)
upload_$(1)_from_work:
$(PGDUMP) --clean --if-exists $(1) | psql -h $(NTG_HOST) -U $(NTG_USER) $(1)
# from home (slow connection, upload bzipped file and then ssh to host)
# bunzip2 -c acts_ph4.pg_dump.sql.bz2 | psql -d acts_ph4
upload_$(1)_from_home:
-rm /tmp/$(1).pg_dump.sql.bz2
$(PGDUMP) --clean --if-exists $(1) | bzip2 > /tmp/$(1).pg_dump.sql.bz2
scp /tmp/$(1).pg_dump.sql.bz2 $(NTG_USER)@$(NTG_HOST):~/
prepare_$(1):
python3 -m scripts.cceh.prepare -vvv instance/$(1).conf
cbgm_$(1):
python3 -m scripts.cceh.cbgm -vvv instance/$(1).conf
load_$(1):
scp $(NTG_PRJ)/backups/saved_edits_$(1)_`date -I`.xml.gz backups/
zcat backups/saved_edits_$(1)_`date -I`.xml.gz | python3 -m scripts.cceh.load_edits -vvv -i - instance/$(1).conf
backup_custom_$(1):
mkdir -p backups/db
$(PGDUMP) -Fc $(1) > backups/db/$(1).`date -I`.custom.dump
backup_sql_$(1):
mkdir -p backups/db
$(PGDUMP) $(1) | gzip > backups/db/$(1).`date -I`.sql.gz
backup_custom_all : backup_custom_$(1)
backup_sql_all : backup_sql_$(1)
endef
$(foreach db,$(DBS),$(eval $(call TEMPLATE,$(db))))
################
upload_client: client-production
$(RSYNC) --exclude "api.conf.js" $(CLIENT)/build/* $(NTG_CLIENT)/
upload_server:
$(RSYNCPY) ntg_common $(NTG_PRJ)/
$(RSYNCPY) server $(NTG_PRJ)/
upload_scripts:
$(RSYNCPY) --exclude "active_databases" scripts/cceh $(NTG_PRJ)/scripts/
$(RSYNC) Makefile $(NTG_PRJ)/
get_remote_backups:
mkdir -p backups/db
$(RSYNC) $(NTG_PRJ)/backups/db backups/
lint: pylint eslint csslint
pylint:
-pylint --rcfile=pylintrc server ntg_common
csslint:
cd client ; make csslint ; cd ..
eslint:
cd client ; make eslint ; cd ..
.PRECIOUS: doc_src/%.jsgraph.dot
doc_src/%.jsgraph.dot : $(CLIENT)/src/js/%.js
madge --dot $< | \
sed -e "s/src\/js\///g" \
-e "s/src\/node_modules\///g" \
-e "s/G {/G {\ngraph [rankdir=\"LR\"]/" > $@
doc_src/%.nolibs.jsgraph.dot : doc_src/%.jsgraph.dot
sed -e "s/.*\/.*//g" $< > $@
%.jsgraph.png : %.jsgraph.dot
dot -Tpng $? > $@
jsgraphs: doc_src/coherence.jsgraph.dot doc_src/comparison.jsgraph.dot \
doc_src/coherence.nolibs.jsgraph.dot doc_src/comparison.nolibs.jsgraph.dot
doc_src/jsdoc/structure.json: $(JS_SRC) $(VUE_SRC)
mkdir -p doc_src/jsdoc/
$(JSDOC) -X $^ > $@
docs: doc_src/jsdoc/structure.json
cd doc_src && $(MAKE) -e html
cp doc_src/_config.yml $(DOCS)/
doccs:
$(RM) -r docs/*
$(MAKE) docs
jsdoc: doc_src/jsdoc/structure.json
sqlacodegen:
sqlacodegen mysql:///ECM_ActsPh4?read_default_group=ntg
sqlacodegen mysql:///VarGenAtt_ActPh4?read_default_group=ntg
%.gzip : %
gzip < $? > $@
install-prerequisites:
sudo apt-get install apache2 libapache2-mod-wsgi-py3 \
postgresql \
python3 python3-pip \
git make graphviz
sudo pip3 install --upgrade pip
sudo pip3 install --upgrade -r server/requirements.txt
sudo pip3 install --upgrade -r scripts/cceh/requirements.txt
install-prerequisites-dev:
sudo apt-get install mariadb-client mariadb-server libpq-dev postgresql-11-mysql-fdw npm plantuml
sudo pip3 install --upgrade \
sphinx sphinx_rtd_theme sphinx_js sphinxcontrib-plantuml
# yum install python34-pip python34-pylint mysql-devel python34-devel node mysql_fdw_10 postgresql10-server
# pip3 install -U setuptools