-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkickstart.sh
135 lines (120 loc) · 3.54 KB
/
kickstart.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
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
#!/bin/bash
# list of supported subdomain
langs="it en de es fr pt sv ca meta pool"
export SALT="secret"
if [[ "$NUM_WORKERS" == "" ]]
then
echo "Default num_workers = 4"
NUM_WORKERS=4
fi
{
cat <<EOF
services:
- name: restbase
module: hyperswitch
conf:
port: 7231
salt: $SALT
default_page_size: 125
user_agent: RESTBase WikiToLearn
ui_name: RESTBase
ui_url: https://www.mediawiki.org/wiki/RESTBase
ui_title: RESTBase docs
spec:
x-request-filters:
- path: lib/security_response_header_filter.js
x-sub-request-filters:
- type: default
name: http
options:
allow:
- pattern: /^http?:\/\/[a-zA-Z0-9\.]+\/api\.php/
forward_headers: true
- pattern: http://mathoid:10044
forward_headers: true
- pattern: http://parsoid:8000
forward_headers: true
- pattern: /^https?:\/\//
paths:
EOF
for lang in $langs ; do
cat <<EOF
/{domain:$lang.$WTL_DOMAIN_NAME}:
x-modules:
- path: projects/wikitolearn.yaml
options:
table:
EOF
if [[ "$CASSANDRA_HOSTS" == "" ]] ; then
cat <<EOF
backend: sqlite
dbname: /db/file.sqlite3
EOF
else
cat <<EOF
backend: cassandra
hosts:
EOF
for CASSANDRA_HOST in $(echo $CASSANDRA_HOSTS | sed 's/,/ /g' )
do
cat <<EOF
- $CASSANDRA_HOST
EOF
done
cat <<EOF
keyspace: system
username: cassandra
password: cassandra
defaultConsistency: one # or 'localQuorum' for production
storage_groups:
- name: $WTL_DOMAIN_NAME
domains: /./
dbname: test.db.sqlite3
EOF
fi
cat <<EOF
pool_idle_timeout: 20000
retry_delay: 250
retry_limit: 10
show_sql: false
action:
apiUriTemplate: "{{'http://{domain}/api.php'}}"
baseUriTemplate: "{{'http://localhost:7231/{domain}/v1/'}}"
parsoid:
host: http://parsoid:8000
mathoid:
host: http://mathoid:10044
# 10 days Varnish caching, one day client-side
cache-control: s-maxage=864000, max-age=86400
related:
cache_control: s-maxage=86400, max-age=86400
# 10 days Varnish caching, one day client-side
purged_cache_control: s-maxage=864000, max-age=86400
EOF
done
cat <<EOF
# A robots.txt to make sure that the content isn't indexed.
/robots.txt:
get:
x-request-handler:
- static:
return:
status: 200
headers:
content-type: text/plain
body: |
User-agent: *
Allow: /*/v1/?doc
Disallow: /
# Finally, a standard service-runner config.
info:
name: restbase
logging:
name: restbase
level: debug
num_workers: $NUM_WORKERS
version: 3 # this MUST BE monotonically increasing
EOF
} > /opt/restbase/config.yaml
sed -i 's/wikimedia.org/pool.'$WTL_DOMAIN_NAME'/g' /opt/restbase/v1/mathoid.yaml
exec node server