-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall-varnish
More file actions
executable file
·69 lines (59 loc) · 2.05 KB
/
install-varnish
File metadata and controls
executable file
·69 lines (59 loc) · 2.05 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
#!/usr/bin/env bash
#ddev-generated
#annertech-ddev
## Description: Install custom annertech varnish config for platform.sh projects
## Usage: install-varnish
## Example: "ddev install-varnish"
uninstall=false
GLOBAL_CONF=~/.ddev/global_config.yaml
SERVICES=.platform/services.yaml
DEV_URL=$(platform url -1 -e dev)
function generate_vcl() {
mkdir -p .platform/varnish
# Don't overwrite the allowlist VCL
cp --no-clobber .ddev/scripts/varnish/varnish_vcls/allowlist.vcl .platform/varnish/
# Generate single config file
# Use project file for allowlist
cat ./.platform/varnish/allowlist.vcl > .platform/config.vcl
# Get latest versions for everything else
cat .ddev/scripts/varnish/varnish_vcls/ai_bots.vcl >> .platform/config.vcl
cat .ddev/scripts/varnish/varnish_vcls/bad_bots.vcl >> .platform/config.vcl
cat .ddev/scripts/varnish/varnish_vcls/good_bots.vcl >> .platform/config.vcl
cat .ddev/scripts/varnish/varnish_vcls/exploit_paths.vcl >> .platform/config.vcl
# This comes last, it contains `sub vcl_recv`
cat .ddev/scripts/varnish/varnish_vcls/config.vcl >> .platform/config.vcl
}
for arg in "$@"; do
if [[ "$arg" == "-u" || "$arg" == "--uninstall" ]]; then
uninstall=true
fi
done
#if [[ $uninstall == true ]]; then
# todo
#fi
if [[ $uninstall == false ]]; then
if grep -q 'ANNERTECH_PLATFORMSH_VARNISH_START' $SERVICES; then
echo "Varnish already installed. Updating VCL"
generate_vcl
else
echo "Adding Varnish to platform.sh"
sed -i 's/upstream: app:http/upstream: varnish:http/g' .platform/routes.yaml
generate_vcl
# Add Varnish services.
cat <<EOL >> $SERVICES
##ANNERTECH_PLATFORMSH_VARNISH_START
varnish:
type: varnish:7.3
relationships:
main: 'app:http'
configuration:
vcl: !include
type: string
path: config.vcl
##ANNERTECH_PLATFORMSH_VARNISH_END
EOL
# Other stuff (test files)
cp --no-clobber .ddev/scripts/varnish/varnish.feature tests/behat/features/varnish.feature
sed -i "s#CHANGE_WITH_URL#$DEV_URL#g" tests/behat/features/varnish.feature
fi
fi