1
1
#! /usr/bin/env bash
2
2
3
- # Enable trace printing and exit on the first error
4
3
set -ex
5
4
6
5
# Get args
@@ -17,18 +16,18 @@ vagrant_dir="/vagrant"
17
16
# Configure Varnish if enabled in config
18
17
restart_services=0
19
18
use_varnish=$( bash " ${vagrant_dir} /scripts/get_config_value.sh" " environment_use_varnish" )
20
- if [ $use_varnish -eq 1 ]; then
19
+ if [[ $use_varnish == 1 ] ]; then
21
20
22
21
# Configure apache files to be ready for varnish
23
- if [ -z " $( grep " VirtualHost\s\*:8080" /etc/apache2/sites-enabled/magento2.conf) " ]; then
22
+ if [[ -z " $( grep " VirtualHost\s\*:8080" /etc/apache2/sites-enabled/magento2.conf) " ] ]; then
24
23
sudo sed -ie " s/<VirtualHost .*/<VirtualHost \*:8080>/" /etc/apache2/sites-enabled/magento2.conf
25
24
restart_services=1
26
25
fi
27
- if [ -z " $( grep " VirtualHost\s\*:8080" /etc/apache2/sites-available/magento2.conf) " ]; then
26
+ if [[ -z " $( grep " VirtualHost\s\*:8080" /etc/apache2/sites-available/magento2.conf) " ] ]; then
28
27
sudo sed -ie " s/<VirtualHost .*/<VirtualHost \*:8080>/" /etc/apache2/sites-available/magento2.conf
29
28
restart_services=1
30
29
fi
31
- if [ -z " $( grep " Listen\s8080" /etc/apache2/ports.conf) " ]; then
30
+ if [[ -z " $( grep " Listen\s8080" /etc/apache2/ports.conf) " ] ]; then
32
31
sudo sed -ie " s/Listen 80/Listen 8080/" /etc/apache2/ports.conf
33
32
restart_services=1
34
33
fi
@@ -42,15 +41,15 @@ if [ $use_varnish -eq 1 ]; then
42
41
else
43
42
44
43
# Configure apache files to run without varnish
45
- if [ -z " $( grep " VirtualHost\s\*:80\b" /etc/apache2/sites-enabled/magento2.conf) " ]; then
44
+ if [[ -z " $( grep " VirtualHost\s\*:80\b" /etc/apache2/sites-enabled/magento2.conf) " ] ]; then
46
45
sudo sed -ie " s/<VirtualHost .*/<VirtualHost \*:80>/" /etc/apache2/sites-enabled/magento2.conf
47
46
restart_services=1
48
47
fi
49
- if [ -z " $( grep " VirtualHost\s\*:80\b" /etc/apache2/sites-available/magento2.conf) " ]; then
48
+ if [[ -z " $( grep " VirtualHost\s\*:80\b" /etc/apache2/sites-available/magento2.conf) " ] ]; then
50
49
sudo sed -ie " s/<VirtualHost .*/<VirtualHost \*:80>/" /etc/apache2/sites-available/magento2.conf
51
50
restart_services=1
52
51
fi
53
- if [ -z " $( grep " Listen\s80\b" /etc/apache2/ports.conf) " ]; then
52
+ if [[ -z " $( grep " Listen\s80\b" /etc/apache2/ports.conf) " ] ]; then
54
53
sudo sed -ie " s/Listen 8080/Listen 80/" /etc/apache2/ports.conf
55
54
restart_services=1
56
55
fi
@@ -68,15 +67,13 @@ if [[ $force_restart_services == 1 ]]; then
68
67
echo " Force restarting Apache and Varnish"
69
68
restart_services=1
70
69
fi
71
- if [ $restart_services -eq 1 ]; then
72
- if [ " $( ps -ax | pgrep varnish) " ]; then
70
+ if [[ $restart_services == 1 ] ]; then
71
+ if [[ " $( ps -ax | pgrep varnish) " ] ]; then
73
72
sudo pkill varnishd
74
73
fi
75
- if [ " $( ps -ax | pgrep apache2) " ]; then
76
- sudo apache2ctl stop
77
- fi
78
- sudo apache2ctl start
79
- if [ $use_varnish -eq 1 ]; then
74
+ sudo service apache2 restart
75
+ if [[ $use_varnish == 1 ]]; then
80
76
sudo varnishd -f /etc/varnish/default.vcl
81
77
fi
78
+ bash " ${vagrant_dir} /scripts/guest/m-clear-cache"
82
79
fi
0 commit comments