Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 0877bf1

Browse files
committed
Implemented collision prevention for IP address and host name (in case when several machines are created at once)
1 parent 44171b2 commit 0877bf1

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
5858
guest_magento_dir, #2
5959
magento_host_name, #3
6060
config_data['environment']['use_php7'], #4
61-
config_data['magento']['backend_frontname'],#5
61+
config_data['magento']['admin_frontname'], #5
6262
config_data['magento']['language'], #6
6363
config_data['magento']['timezone'], #8
6464
config_data['magento']['currency'], #9

init_project.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
vagrant_dir=$PWD
44
magento_ce_dir="${vagrant_dir}/magento2ce"
55
magento_ee_dir="${magento_ce_dir}/magento2ee"
6+
config_path="${vagrant_dir}/local.config/config.yaml"
67

78
# Enable trace printing and exit on the first error
89
set -ex
910

1011
bash "${vagrant_dir}/scripts/host/shell/check_requirements.sh"
1112

13+
# Generate random IP address and host name to prevent collisions, if not specified explicitly in local config
14+
if [ ! -f "${vagrant_dir}/local.config/config.yaml" ]; then
15+
cp "${config_path}.dist" ${config_path}
16+
fi
17+
random_ip=$(( ( RANDOM % 240 ) + 12 ))
18+
sed -i.back "s|ip_address: \"192.168.10.2\"|ip_address: \"192.168.10.${random_ip}\"|g" "${config_path}"
19+
sed -i.back "s|host_name: \"magento2.vagrant2\"|host_name: \"magento2.vagrant${random_ip}\"|g" "${config_path}"
20+
rm -f "${config_path}.back"
21+
22+
# Clean up the project before initialization if "-f" option was specified
1223
force_project_cleaning=0
1324
while getopts 'f' flag; do
1425
case "${flag}" in
1526
f) force_project_cleaning=1 ;;
1627
*) error "Unexpected option ${flag}" ;;
1728
esac
1829
done
19-
20-
# Clean up the project before initialization if "-f" option was specified
2130
if [ ${force_project_cleaning} -eq 1 ]; then
2231
vagrant destroy -f
2332
rm -rf ${magento_ce_dir} ${vagrant_dir}/.idea ${vagrant_dir}/.vagrant

local.config/config.yaml.dist

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ guest:
66
use_nfs: 1
77
# Default is 2Gb, around 3Gb is necessary to run functional tests
88
memory: 2048
9-
ip_address: "192.168.10.11"
9+
ip_address: "192.168.10.2"
1010
environment:
1111
# If set to 0, PHP 5 will be installed
1212
use_php7: 1
1313
magento:
14-
host_name: "magento2.vagrant"
15-
backend_frontname: "admin"
14+
host_name: "magento2.vagrant2"
15+
admin_frontname: "admin"
1616
language: "en_US"
1717
timezone: "America/Chicago"
1818
currency: "USD"

scripts/provision/install_magento.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ guest_magento_dir=$2
1010
magento_host_name=$3
1111

1212
declare -A setupOptions
13-
setupOptions[backend_frontname]=$5
13+
setupOptions[admin_frontname]=$5
1414
setupOptions[language]=$6
1515
setupOptions[timezone]=$7
1616
setupOptions[currency]=$8
@@ -50,7 +50,7 @@ install_cmd="./bin/magento setup:install \
5050
--db-host=${setupOptions[db_host]} \
5151
--db-name=${setupOptions[db_name]} \
5252
--db-user=${setupOptions[db_user]} \
53-
--backend-frontname=${setupOptions[backend_frontname]} \
53+
--backend-frontname=${setupOptions[admin_frontname]} \
5454
--base-url=${setupOptions[base_url]} \
5555
--language=${setupOptions[language]} \
5656
--timezone=${setupOptions[timezone]} \
@@ -86,7 +86,7 @@ set +x
8686
echo "
8787
Magento application was deployed to ${guest_magento_dir} and installed successfully
8888
Access storefront at ${setupOptions[base_url]}
89-
Access admin panel at ${setupOptions[base_url]}${setupOptions[backend_frontname]}/"
89+
Access admin panel at ${setupOptions[base_url]}${setupOptions[admin_frontname]}/"
9090

9191
if [ ${use_nfs_for_synced_folders} -eq 0 ]; then
9292
echo "

0 commit comments

Comments
 (0)