forked from Yoast/plugin-development-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·63 lines (55 loc) · 2.2 KB
/
make.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
#!/bin/bash
cp -n config/php.ini.default config/php.ini
cp -n config/config.sh.default config/config.sh
chmod u+x config/config.sh
kill_port_80_usage () {
echo "checking if port 80 is free to use"
if lsof -nP +c 15 | grep LISTEN | grep -q -E ":80"; then
select yn in "Stop apachectl to use docker" "Leave it (I will fix it myself!)"; do
case $yn in
"Stop apachectl so we can use docker" )
echo need sudo to STOP apachectl
sudo apachectl start
break
;;
"Leave it (I will fix it myself!)" ) break;;
esac
done
else
echo "OK"
fi
}
change_hostfile () {
local URL=$1
echo "checking hostfile entry for: $URL"
if grep -q -E "^([0-9]{1,3}[\.]){3}[0-9]{1,3}[[:space:]]+$URL" /etc/hosts; then
if grep -q -E "^127\.0\.0\.1[[:space:]]+$URL" /etc/hosts; then
echo OK
else
echo "Found this entry for: $URL"
grep -E "^([0-9]{1,3}[\.]){3}[0-9]{1,3}[[:space:]]+$URL" /etc/hosts;
select yn in "Change it to use docker" "Leave it"; do
case $yn in
"Change it to use docker" )
echo need sudo to edit hostfile
grep -v -E "^([0-9]{1,3}[\.]){3}[0-9]{1,3}[[:space:]]+$URL" /etc/hosts | sudo tee /etc/hosts > /dev/null
echo "127.0.0.1 $URL" | sudo tee -a /etc/hosts > /dev/null
break
;;
"Leave it" ) break;;
esac
done
fi
else
echo adding $URL to hostfile need sudo
echo "127.0.0.1 $URL" | sudo tee -a /etc/hosts > /dev/null
fi
}
source ./config/config.sh
change_hostfile ${BASIC_HOST:-basic.wordpress.test}
change_hostfile ${WOOCOMMERCE_HOST:-woocommerce.wordpress.test}
change_hostfile ${MULTISITE_HOST:-multisite.wordpress.test}
change_hostfile ${BASIC_DATABASE_HOST:-basic-database.wordpress.test}
change_hostfile ${WOOCOMMERCE_DATABASE_HOST:-woocommerce-database.wordpress.test}
change_hostfile ${MULTISITE_DATABASE_HOST:-multisite-database.wordpress.test}
kill_port_80_usage