-
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathtest-generate
More file actions
executable file
·101 lines (93 loc) · 2.78 KB
/
test-generate
File metadata and controls
executable file
·101 lines (93 loc) · 2.78 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
#!/bin/sh
if [ "$3" = "saml" ]; then
TEST_EXTRA_ENV='WEBLATE_SAML_IDP_URL: https://example.com/idp'
elif [ "$3" = "celery-single" ]; then
TEST_EXTRA_ENV='CELERY_SINGLE_PROCESS: 1'
elif [ "$3" = "anubis" ]; then
TEST_EXTRA_ENV='WEBLATE_ANUBIS_URL: http://anubis:8923'
else
TEST_EXTRA_ENV=''
fi
cat > docker-compose.override.yml << EOT
services:
weblate:
image: ${TEST_CONTAINER:-weblate/weblate:edge}
restart: no
environment:
WEBLATE_TIME_ZONE: Europe/Prague
WEBLATE_SITE_DOMAIN: test.example.com
WEBLATE_SILENCED_SYSTEM_CHECKS: weblate.E003,weblate.E011,weblate.E012,weblate.E013,weblate.E017,security.W004,security.W008,security.W012,security.W018,weblate.I021,weblate.E016,weblate.I028,weblate.C030,otp_webauthn.E031
${TEST_EXTRA_ENV}
ports:
- 8080:8080
- 4443:4443
EOT
if [ "$3" = "anubis" ]; then
cat > botPolicy.yaml << EOT
bots:
- name: well-known
path_regex: ^/.well-known/.*$
action: ALLOW
- name: favicon
path_regex: ^/favicon.ico$
action: ALLOW
- name: robots-txt
path_regex: ^/robots.txt$
action: ALLOW
- name: generic-browser
user_agent_regex: Mozilla
action: CHALLENGE
EOT
cat >> docker-compose.override.yml << EOT
depends_on:
- anubis
anubis:
image: ghcr.io/techarohq/anubis:latest
environment:
BIND: ":8923"
DIFFICULTY: "4"
METRICS_BIND: ":9090"
SERVE_ROBOTS_TXT: "false"
TARGET: " "
POLICY_FNAME: "/data/cfg/botPolicy.yaml"
OG_PASSTHROUGH: "false"
ED25519_PRIVATE_KEY_HEX: "$(openssl rand -hex 32)"
volumes:
- "./botPolicy.yaml:/data/cfg/botPolicy.yaml:ro"
EOT
fi
if [ "$3" = "split" ]; then
mv docker-compose-split.yml docker-compose.yml
for service in celery-backup celery-beat celery-celery celery-memory celery-notify celery-translate; do
cat >> docker-compose.override.yml << EOT
weblate-${service}:
image: ${TEST_CONTAINER:-weblate/weblate:edge}
restart: no
environment:
WEBLATE_TIME_ZONE: Europe/Prague
WEBLATE_SITE_DOMAIN: test.example.com
EOT
done
fi
if [ "$3" = "read-write" ] || [ "$3" = "localtime" ]; then
sed -i -e '/tmpfs:/D' -e '/- \/run/D' -e '/- \/tmp/D' -e '/read_only: true/D' docker-compose.yml
if [ "$3" = "localtime" ]; then
sed -i -e '/weblate-cache:\/app\/cache/a\
- /etc/localtime:/etc/localtime:ro' docker-compose.yml
fi
else
# Allow execution in tmp
sed -i 's/- \/tmp/- \/tmp:exec/' docker-compose.yml
fi
IP=127.0.0.1
PORT=${1:-8080}
PROTO=${2:-http}
cat > .test.env << EOT
URL=$PROTO://$IP:$PORT/
EOT
echo "Weblate will be running on $PROTO://$IP:$PORT/"
echo
echo "Weblate configuration (docker.compose.yml):"
cat docker-compose.yml
echo "Weblate configuration (docker.compose.override.yml):"
cat docker-compose.override.yml