From 40b6a39c10815e582950750147c11d7f342319db Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Fri, 12 Feb 2016 16:37:24 +0200 Subject: [PATCH 001/173] Added host wrapper script for bin/magento on the guest --- CHANGELOG.md | 2 +- README.md | 11 +++++++++++ m-bin-magento | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 m-bin-magento diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a9a0045565..23cf3d7d364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -Nothing yet + - Added host wrapper script for bin/magento command on guest ## [v2.0.0] - 2016-02-05 diff --git a/README.md b/README.md index e0eb28b1937..0aa02ead18f 100755 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ * [Clear magento cache](#clear-magento-cache) * [Update composer dependencies](#update-composer-dependencies) * [Switch between CE and EE](#switch-between-ce-and-ee) + * [Use Magento CLI (bin/magento)](#use-magento-cli-binmagento) * [Debugging with XDebug](#debugging-with-xdebug) * [Multiple Magento instances](#multiple-magento-instances) @@ -169,6 +170,16 @@ OR bash m-composer update ``` +### Use Magento CLI (bin/magento) + +Go to 'vagrant-magento' created earlier and run in command line: + +``` +bash m-bin-magento +e.g. +bash m-bin-magento list +``` + ### Debugging with XDebug XDebug is already configured to connect to the host machine automatically. So just: diff --git a/m-bin-magento b/m-bin-magento new file mode 100755 index 00000000000..a4356a72ba5 --- /dev/null +++ b/m-bin-magento @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +vagrant_dir=$(cd "$(dirname "$0")"; pwd) + +# Enable trace printing and exit on the first error +set -ex + +arguments=$@ +cd ${vagrant_dir} +vagrant ssh -c "\$MAGENTO_ROOT/bin/magento $arguments" \ No newline at end of file From 07e00139d3cf702b583d3a03f83ea14be0a47ce0 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Mon, 15 Feb 2016 14:03:49 +0200 Subject: [PATCH 002/173] Added pause while uploading files for Windows/OS without NFS --- README.md | 5 +++++ m-switch-to-ce | 6 ++++++ m-switch-to-ee | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 0aa02ead18f..75dc650e025 100755 --- a/README.md +++ b/README.md @@ -159,6 +159,11 @@ bash m-switch-to-ce OR bash m-switch-to-ee ``` +:information_source: ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) On OSX and \*nix hosts without NFS +you will be asked to wait until uploading process is finished. To continue the process you need to press any key. +process is finished. To continue the process you need to press any key. +:information_source: ![](docs/images/windows-icon.png) On Windows hosts you will be asked to wait until uploading +process is finished. To continue the process you need to press any key. ### Update composer dependencies diff --git a/m-switch-to-ce b/m-switch-to-ce index d6896ef4928..28ca5958bc9 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -37,4 +37,10 @@ fi bash "${vagrant_dir}/m-clear-cache" bash -c "${vagrant_dir}/m-composer install" + +echo "Magento installation..." +if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then + read -p "Wait while Magento2 code is uploaded and press any key to continue..." -n1 -s +fi + bash "${vagrant_dir}/m-reinstall" \ No newline at end of file diff --git a/m-switch-to-ee b/m-switch-to-ee index 360321df19f..97453341a7e 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -38,4 +38,10 @@ fi bash "${vagrant_dir}/m-clear-cache" bash -c "${vagrant_dir}/m-composer install" + +echo "Magento installation..." +if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then + read -p "Wait while Magento2 code is uploaded and press any key to continue..." -n1 -s +fi + bash "${vagrant_dir}/m-reinstall" \ No newline at end of file From feb35fd40117a6f9eed74849a7240f8acc25b0e5 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 17 Feb 2016 14:21:37 +0200 Subject: [PATCH 003/173] Fixed permissions after Magento installation on Windows hosts --- scripts/guest/m-reinstall | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index af75aa00b8a..a7fbd49a5db 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -4,7 +4,6 @@ set -ex get_config_value="/vagrant/scripts/get_config_value.sh" -use_nfs_for_synced_folders=$(bash ${get_config_value} "guest_use_nfs") magento_host_name=$(bash ${get_config_value} "magento_host_name") declare -A setupOptions @@ -76,7 +75,7 @@ php ${install_cmd} # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - -if [ ${use_nfs_for_synced_folders} -eq 0 ]; then +if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then chown -R vagrant:vagrant ${MAGENTO_ROOT} fi @@ -90,7 +89,7 @@ Magento application was deployed to ${MAGENTO_ROOT} and installed successfully Access storefront at ${setupOptions[base_url]} Access admin panel at ${setupOptions[base_url]}${setupOptions[admin_frontname]}/" -if [ ${use_nfs_for_synced_folders} -eq 0 ]; then +if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then echo " [Optional] To finish developer environment set up: 1. Please create new PhpStorm project using 'magento2ce' directory on your host From 421ecd62ff41d574252004f262de06ec8f1d0e68 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 17 Feb 2016 14:36:14 +0200 Subject: [PATCH 004/173] Fixed permissions after Magento installation on Windows hosts --- CHANGELOG.md | 6 ++++++ scripts/guest/m-reinstall | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23cf3d7d364..429c3e05f3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Fixed + + - Fixed permissions during Magento installation on Windows hosts + +### Added + - Added host wrapper script for bin/magento command on guest ## [v2.0.0] - 2016-02-05 diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index a7fbd49a5db..a0ccc38d17f 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -75,7 +75,9 @@ php ${install_cmd} # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") +use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") +if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then chown -R vagrant:vagrant ${MAGENTO_ROOT} fi @@ -89,7 +91,7 @@ Magento application was deployed to ${MAGENTO_ROOT} and installed successfully Access storefront at ${setupOptions[base_url]} Access admin panel at ${setupOptions[base_url]}${setupOptions[admin_frontname]}/" -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then echo " [Optional] To finish developer environment set up: 1. Please create new PhpStorm project using 'magento2ce' directory on your host From 1693ee7d14a52335fc75bdb15750601d037df088 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 17 Feb 2016 17:44:10 +0200 Subject: [PATCH 005/173] Fixed permissions after Magento installation on Windows hosts --- Vagrantfile | 8 +++++++- scripts/guest/m-reinstall | 7 ++++--- scripts/provision/configure_environment.sh | 2 ++ scripts/provision/export_env_variables.sh | 12 ++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100755 scripts/provision/export_env_variables.sh diff --git a/Vagrantfile b/Vagrantfile index 8d8ea24cb1e..ec3d37febf1 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -63,7 +63,8 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| guest_magento_dir, #2 magento_host_name, #3 config_data['environment']['use_php7'], #4 - host_magento_dir #5 + host_magento_dir, #5 + OS.is_windows ? "1" : "0" #6 ] config.vm.provision "configure_environment", type: "shell" do |s| @@ -71,6 +72,11 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| s.args = shell_script_args end + config.vm.provision "export_env_variables", type: "shell", run: "always" do |s| + s.path = "scripts/provision/export_env_variables.sh" + s.args = shell_script_args + end + if !use_nfs_for_synced_folders config.vm.provision "host_compress_magento_code", type: "host_shell", inline: "tar cf scripts/host/magento2ce.tar magento2ce" config.vm.provision "guest_uncompress_magento_code", type: "shell", inline: "mkdir -p /var/www && tar xf /vagrant/scripts/host/magento2ce.tar -C /var/www &>/dev/null" diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index a0ccc38d17f..33296a61864 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -5,6 +5,7 @@ set -ex get_config_value="/vagrant/scripts/get_config_value.sh" magento_host_name=$(bash ${get_config_value} "magento_host_name") +vagrant_dir="/vagrant" declare -A setupOptions setupOptions[admin_frontname]=$(bash ${get_config_value} "magento_admin_frontname") @@ -75,9 +76,9 @@ php ${install_cmd} # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - -host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") -if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then +is_windows_host=${IS_WINDOWS_HOST} +if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then chown -R vagrant:vagrant ${MAGENTO_ROOT} fi @@ -91,7 +92,7 @@ Magento application was deployed to ${MAGENTO_ROOT} and installed successfully Access storefront at ${setupOptions[base_url]} Access admin panel at ${setupOptions[base_url]}${setupOptions[admin_frontname]}/" -if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then +if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then echo " [Optional] To finish developer environment set up: 1. Please create new PhpStorm project using 'magento2ce' directory on your host diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index bf1450b89d9..a65e63dd776 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -8,6 +8,7 @@ guest_magento_dir=$2 magento_host_name=$3 use_php7=$4 host_magento_dir=$5 +is_windows_host=$6 vagrant_dir="/vagrant" @@ -71,6 +72,7 @@ fi echo "export PATH=\$PATH:${vagrant_dir}/scripts/guest:${guest_magento_dir}/bin" >> /etc/profile echo "export MAGENTO_ROOT=${guest_magento_dir}" >> /etc/profile echo "export MAGENTO_ROOT_HOST=${host_magento_dir}" >> /etc/profile +echo "export IS_WINDOWS_HOST=${is_windows_host}" >> /etc/profile # Set permissions to allow Magento codebase upload by Vagrant provision script if [ ${use_nfs_for_synced_folders} -eq 0 ]; then diff --git a/scripts/provision/export_env_variables.sh b/scripts/provision/export_env_variables.sh new file mode 100755 index 00000000000..c7e0eee3138 --- /dev/null +++ b/scripts/provision/export_env_variables.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Enable trace printing and exit on the first error +set -e + +guest_magento_dir=$2 +host_magento_dir=$5 +is_windows_host=$6 + +export MAGENTO_ROOT=${guest_magento_dir} +export MAGENTO_ROOT_HOST=${host_magento_dir} +export IS_WINDOWS_HOST=${is_windows_host} From cf8f94747dc7c5290187dabf84d1f3fa193375e9 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Wed, 17 Feb 2016 17:44:55 +0200 Subject: [PATCH 006/173] Updated doc and messages. Added known-issues doc --- README.md | 4 ++-- docs/known-issues.md | 10 ++++++++++ m-switch-to-ce | 2 +- m-switch-to-ee | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 docs/known-issues.md diff --git a/README.md b/README.md index 75dc650e025..d49420163d1 100755 --- a/README.md +++ b/README.md @@ -160,10 +160,10 @@ OR bash m-switch-to-ee ``` :information_source: ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) On OSX and \*nix hosts without NFS -you will be asked to wait until uploading process is finished. To continue the process you need to press any key. +you will be asked to wait until uploading process in PhpStorm is finished(PhpStorm should be lunched). To continue the process you need to press any key. process is finished. To continue the process you need to press any key. :information_source: ![](docs/images/windows-icon.png) On Windows hosts you will be asked to wait until uploading -process is finished. To continue the process you need to press any key. +process in PhpStorm is finished(PhpStorm should be lunched). To continue the process you need to press any key. ### Update composer dependencies diff --git a/docs/known-issues.md b/docs/known-issues.md new file mode 100644 index 00000000000..0bb141367b2 --- /dev/null +++ b/docs/known-issues.md @@ -0,0 +1,10 @@ +Known issues +---------------------------- + +1. PHP Warning: require(/var/www/magento2ce/app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directory + Check modified files from /var/www/magento2ce/app/etc/ in git and revert them. + +2. Guest system behaves wierd, e.g. install process can be suddenly killed. + Try to increase memory for guest machine. + + diff --git a/m-switch-to-ce b/m-switch-to-ce index 28ca5958bc9..c564018eac3 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -40,7 +40,7 @@ bash -c "${vagrant_dir}/m-composer install" echo "Magento installation..." if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then - read -p "Wait while Magento2 code is uploaded and press any key to continue..." -n1 -s + read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s fi bash "${vagrant_dir}/m-reinstall" \ No newline at end of file diff --git a/m-switch-to-ee b/m-switch-to-ee index 97453341a7e..9cedf80fea9 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -41,7 +41,7 @@ bash -c "${vagrant_dir}/m-composer install" echo "Magento installation..." if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then - read -p "Wait while Magento2 code is uploaded and press any key to continue..." -n1 -s + read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s fi bash "${vagrant_dir}/m-reinstall" \ No newline at end of file From 1753c0536dc56dc04b95b09542f75ea0fef341f9 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Tue, 1 Mar 2016 11:44:07 +0200 Subject: [PATCH 007/173] [github] Invalid link provided in [optional instruction] #7 --- scripts/guest/m-reinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 33296a61864..4a3b85817cc 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -98,6 +98,6 @@ if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then 1. Please create new PhpStorm project using 'magento2ce' directory on your host (this directory should already contain Magento repository cloned earlier) - 2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/master/docs/phpstorm-configuration-windows-hosts.md + 2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/2.0/docs/phpstorm-configuration-windows-hosts.md to set up synchronization in PhpStorm (or using rsync) with ${MAGENTO_ROOT} directory" fi From 592e5794b57fe87c047f2c3eeb75a2e376cfb0c0 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Tue, 15 Mar 2016 14:13:54 -0500 Subject: [PATCH 008/173] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d49420163d1..19212cae54f 100755 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ * [Switch between CE and EE](#switch-between-ce-and-ee) * [Use Magento CLI (bin/magento)](#use-magento-cli-binmagento) * [Debugging with XDebug](#debugging-with-xdebug) + * [Connecting to MySQL DB](#connecting-to-mysql-db) * [Multiple Magento instances](#multiple-magento-instances) ## What You get @@ -193,6 +194,10 @@ XDebug is already configured to connect to the host machine automatically. So ju 1. Start listening for PHP Debug connections in PhpStorm on default 9000 port. See how to [integrate XDebug with PhpStorm](https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html#integrationWithProduct) 1. Set beakpoint or set option in PhpStorm menu 'Run -> Break at first line in PHP scripts' +### Connecting to MySQL DB + +Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-developers/issues/8) + ### Multiple Magento instances To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host. From 85c942a949820e25e293344816ef94ca3b84c8d9 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Tue, 5 Apr 2016 13:13:15 -0500 Subject: [PATCH 009/173] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 19212cae54f..436e8d26090 100755 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik :information_source: ![](docs/images/windows-icon.png) On Windows hosts you might face `Composer Install Error: ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)` exception during `composer install`. This can be fixed in 2 ways: decrease path length to the project directory or set `composer_prefer_source` option in [config.yaml](etc/config.yaml.dist) to `1` 1. Use `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`). This is important, because in this case PHP Storm will be configured automatically by [init_project.sh](init_project.sh). If NFS files sync is disabled in [config](etc/config.yaml.dist) and ![](docs/images/windows-icon.png) on Windows hosts [verify deployment configuration in PHP Storm](docs/phpstorm-configuration-windows-hosts.md) + + 1. Configure remote PHP interpreter in PHP Storm. Go to `Settings => Languages & Frameworks => PHP`, add new remote interpreter and select "Deployment configuration" as a source for connection details. ### Default credentials and settings From c10b6ffa49fc5427c50d660a5fa9f2a2950d2b00 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 6 Apr 2016 15:35:27 -0500 Subject: [PATCH 010/173] Added sample data support via "-s" option during reinstall or switching between CE and EE --- etc/config.yaml.dist | 2 ++ init_project.sh | 11 +++++++ m-reinstall | 63 +++++++++++++++++++++++++++++++++++++++ m-switch-to-ce | 16 +++++++++- m-switch-to-ee | 16 +++++++++- scripts/guest/m-reinstall | 2 ++ 6 files changed, 108 insertions(+), 2 deletions(-) diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index 92dcd23c89c..8ea77f33cbc 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -1,6 +1,8 @@ repository_url: ce: "git@github.com:magento/magento2.git" ee: "" + ce_sample_data: "git@github.com:magento/magento2-sample-data.git" + ee_sample_data: "" guest: # NFS will be used for folder synchronization on *nix and OSX hosts by default use_nfs: 1 diff --git a/init_project.sh b/init_project.sh index ba225a25f76..01d31a37c13 100755 --- a/init_project.sh +++ b/init_project.sh @@ -2,7 +2,9 @@ vagrant_dir=$PWD magento_ce_dir="${vagrant_dir}/magento2ce" +magento_ce_sample_data_dir="${magento_ce_dir}/magento2ce-sample-data" magento_ee_dir="${magento_ce_dir}/magento2ee" +magento_ee_sample_data_dir="${magento_ce_dir}/magento2ee-sample-data" config_path="${vagrant_dir}/etc/config.yaml" host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") @@ -61,12 +63,21 @@ if [ ! -d ${magento_ce_dir} ]; then # Check out CE repository repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce") git clone ${repository_url_ce} ${magento_ce_dir} + # Check out CE sample data repository + repository_url_ce_sample_data=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce_sample_data") + git clone ${repository_url_ce_sample_data} ${magento_ce_sample_data_dir} # Check out EE repository # By default EE repository is not specified and EE project is not checked out repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee") if [ -n "${repository_url_ee}" ]; then git clone ${repository_url_ee} ${magento_ee_dir} fi + # Check out EE sample data repository + # By default EE sample data repository is not specified and EE project is not checked out + repository_url_ee_sample_data=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee_sample_data") + if [ -n "${repository_url_ee_sample_data}" ]; then + git clone ${repository_url_ee_sample_data} ${magento_ee_sample_data_dir} + fi fi # Update Magento dependencies via Composer diff --git a/m-reinstall b/m-reinstall index 1ed9b9a6808..359d2436c7b 100755 --- a/m-reinstall +++ b/m-reinstall @@ -1,9 +1,72 @@ #!/usr/bin/env bash vagrant_dir=$(cd "$(dirname "$0")"; pwd) +magento_ce_dir="${vagrant_dir}/magento2ce" +magento_ce_sample_data_dir="${magento_ce_dir}/magento2ce-sample-data" +magento_ee_sample_data_dir="${magento_ce_dir}/magento2ee-sample-data" +php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error set -ex +with_sample_data=0 +while [ "$1" != "" ]; do + case $1 in + -s | --sample-data ) with_sample_data=1 + ;; + * ) ;; + esac + shift +done + +# As a precondition, disable CE sample data +if [ -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php ]; then + ${php_executable} -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php -- --command=unlink --ce-source="${magento_ce_dir}" --sample-data-source="${magento_ce_sample_data_dir}" + set +x + echo "CE Sample data disabled" + set -x +fi +# As a precondition, disable EE sample data +if [ -f ${magento_ee_sample_data_dir}/dev/tools/build-sample-data.php ]; then + ${php_executable} -f ${magento_ee_sample_data_dir}/dev/tools/build-sample-data.php -- --command=unlink --ce-source="${magento_ce_dir}" --sample-data-source="${magento_ee_sample_data_dir}" + set +x + echo "EE Sample data disabled" + set -x +fi + +if [ ${with_sample_data} = 1 ]; then + # Installing CE or EE, in both cases CE sample data should be linked + if [ ! -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php ]; then + # Sample data not available and should be enabled + set +x + echo "CE Sample data repository is not available. Recreate project using \"init_project.sh -fc\", which will delete Magento code base and recreate project from scratch. Or clone sample data to /magento2ce/magento2ce-sample-data." + set -x + exit 0 + else + # Sample data available and should be enabled + set +x + echo "CE Sample data enabled" + set -x + ${php_executable} -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php -- --command=link --ce-source="${magento_ce_dir}" --sample-data-source="${magento_ce_sample_data_dir}" + fi + + if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then + # Installing EE + if [ ! -f ${magento_ee_sample_data_dir}/dev/tools/build-sample-data.php ]; then + # Sample data not available and should be enabled + set +x + echo "EE Sample data repository is not available. Recreate project using \"init_project.sh -fc\", which will delete Magento code base and recreate project from scratch. Or clone sample data to /magento2ce/magento2ee-sample-data." + set -x + exit 0 + else + # Sample data available and should be enabled + set +x + echo "EE Sample data enabled" + set -x + ${php_executable} -f ${magento_ee_sample_data_dir}/dev/tools/build-sample-data.php -- --command=link --ce-source="${magento_ce_dir}" --sample-data-source="${magento_ee_sample_data_dir}" + fi + fi +fi + cd ${vagrant_dir} vagrant ssh -c "m-reinstall" \ No newline at end of file diff --git a/m-switch-to-ce b/m-switch-to-ce index c564018eac3..2052ccbdca0 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -9,6 +9,16 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error set -ex +with_sample_data=0 +while [ "$1" != "" ]; do + case $1 in + -s | --sample-data ) with_sample_data=1 + ;; + * ) ;; + esac + shift +done + if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then echo "EE codebase is not available" exit 0 @@ -43,4 +53,8 @@ if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s fi -bash "${vagrant_dir}/m-reinstall" \ No newline at end of file +if [ ${with_sample_data} = 1 ]; then + bash "${vagrant_dir}/m-reinstall" --sample-data +else + bash "${vagrant_dir}/m-reinstall" +fi diff --git a/m-switch-to-ee b/m-switch-to-ee index 9cedf80fea9..656b4d9771b 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -9,6 +9,16 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error set -ex +with_sample_data=0 +while [ "$1" != "" ]; do + case $1 in + -s | --sample-data ) with_sample_data=1 + ;; + * ) ;; + esac + shift +done + if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then echo "EE codebase is not available" exit 0 @@ -44,4 +54,8 @@ if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s fi -bash "${vagrant_dir}/m-reinstall" \ No newline at end of file +if [ ${with_sample_data} = 1 ]; then + bash "${vagrant_dir}/m-reinstall" --sample-data +else + bash "${vagrant_dir}/m-reinstall" +fi \ No newline at end of file diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 4a3b85817cc..ca80e18e53f 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -72,6 +72,8 @@ fi chmod +x bin/magento php ${install_cmd} +# Comment out the line above and uncomment the one below to debug setup script, make sure to verify remote_host value +# php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - From 6f55db2a0db01277983a8d27a49de3e1cfa82b5d Mon Sep 17 00:00:00 2001 From: Olga Kopylova Date: Thu, 7 Apr 2016 23:40:55 -0500 Subject: [PATCH 011/173] Remove github token requirement - removed token from config - removed GitHub limitations section from Readme --- README.md | 15 ++------------- etc/composer/auth.json.dist | 3 --- scripts/host/check_requirements.sh | 7 ------- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 436e8d26090..014c6b9fca5 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ * [Installation steps](#installation-steps) * [Default credentials and settings](#default-credentials-and-settings) * [Getting updates and fixes](#getting-updates-and-fixes) - * [GitHub limitations](#github-limitations) * [Day-to-day development scenarios](#day-to-day-development-scenarios) * [Reinstall Magento](#reinstall-magento) * [Clear magento cache](#clear-magento-cache) @@ -71,8 +70,8 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik git clone git@github.com:paliarush/magento2-vagrant-for-developers.git vagrant-magento ``` - 1. Copy [etc/composer/auth.json.dist](etc/composer/auth.json.dist) to `etc/composer/auth.json` and specify your [GitHub OAuth token](https://github.com/settings/tokens) there. See [API rate limit and OAuth tokens](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens) for more information - + 1. Copy [etc/composer/auth.json.dist](etc/composer/auth.json.dist) to `etc/composer/auth.json` + 1. Optionally, copy [etc/config.yaml.dist](etc/config.yaml.dist) as `etc/config.yaml` and make necessary customizations 1. Initialize project, configure environment, install Magento, configure PHPStorm project: @@ -121,16 +120,6 @@ Current vagrant project follows [semantic versioning](http://semver.org/spec/v2. For example your current branch is `2.0`, then it will be safe to pull any changes from `origin/2.0`. However branch `3.0` will contain changes backward incompatible with `2.0`. Note, that semantic versioning is only used for `x.0` branches (not for `develop`). -### GitHub limitations - -Be aware that you may encounter GitHub limits on the number of downloads (used by Composer to download Magento dependencies). - -These limits may significantly slow down the installation since all of the libraries will be cloned from GitHub repositories instead of downloaded as ZIP archives. In the worst case, these limitations may even terminate the installation. - -If you have a GitHub account, you can bypass these limitations by using an OAuth token in the Composer configuration. See [API rate limit and OAuth tokens](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens) for more information. - -For the Vagrant configuration you may specify your token in `etc/github.oauth.token` file after cloning the repository. The file is a basic text file and is ignored by Git, so you'll need to create it yourself. Simply write your OAuth token in this file making sure to avoid any empty spaces, and it will be read during deployment. - ## Day-to-day development scenarios ### Reinstall Magento diff --git a/etc/composer/auth.json.dist b/etc/composer/auth.json.dist index 1058d7070ba..314d65151cc 100644 --- a/etc/composer/auth.json.dist +++ b/etc/composer/auth.json.dist @@ -1,7 +1,4 @@ { - "github-oauth": { - "github.com": "your-github-token" - }, "http-basic": { "repo.magento.com": { "username": "your-magento-repo-public-key", diff --git a/scripts/host/check_requirements.sh b/scripts/host/check_requirements.sh index b32f91c6870..75f8560e7ce 100755 --- a/scripts/host/check_requirements.sh +++ b/scripts/host/check_requirements.sh @@ -10,10 +10,3 @@ set -ex if ! ${php_executable} -v | grep -q 'Copyright' ; then bash "${vagrant_dir}/scripts/host/install_php.sh" fi - -if [ ! -f ${composer_auth_json} ]; then - set +x - echo "Please specify GitHub token in ${composer_auth_json} to bypass GitHub rate limits (see https://github.com/paliarush/magento2-vagrant-for-developers/tree/develop#github-limitations)" - exit 255 - set -x -fi \ No newline at end of file From 40b09b03c6eb0870cdb1ed78c895799c3eac0734 Mon Sep 17 00:00:00 2001 From: Igor Melnikov Date: Fri, 8 Apr 2016 11:29:37 -0500 Subject: [PATCH 012/173] Remove GitHub token requirement Adding placeholder to auth.json.dist, updating documentation --- README.md | 6 +++++- etc/composer/auth.json.dist | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 014c6b9fca5..b9bf71dfc14 100755 --- a/README.md +++ b/README.md @@ -70,7 +70,11 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik git clone git@github.com:paliarush/magento2-vagrant-for-developers.git vagrant-magento ``` - 1. Copy [etc/composer/auth.json.dist](etc/composer/auth.json.dist) to `etc/composer/auth.json` + 1. Optionally, if you use private repositories on GitHub or download packages from Magento Marketplace + + - copy [etc/composer/auth.json.dist](etc/composer/auth.json.dist) to `etc/composer/auth.json` + - specify your GitHub token by adding `"github.com": "your-github-token"` to `github-oauth` section for GitHub authorization + - add Magento Marketplace keys for Marketplace authorization 1. Optionally, copy [etc/config.yaml.dist](etc/config.yaml.dist) as `etc/config.yaml` and make necessary customizations diff --git a/etc/composer/auth.json.dist b/etc/composer/auth.json.dist index 314d65151cc..024c557834c 100644 --- a/etc/composer/auth.json.dist +++ b/etc/composer/auth.json.dist @@ -1,4 +1,6 @@ { + "github-oauth": { + }, "http-basic": { "repo.magento.com": { "username": "your-magento-repo-public-key", From c3cdea3352a5f5ed54eed31cfe6e332be5a2929f Mon Sep 17 00:00:00 2001 From: Igor Melnikov Date: Fri, 8 Apr 2016 14:10:58 -0500 Subject: [PATCH 013/173] Remove GitHub token requirement Check if auth.json exists before copying --- scripts/host/check_requirements.sh | 1 - scripts/host/composer.sh | 9 +++++++-- scripts/host/configure_php_storm.sh | 1 - 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/host/check_requirements.sh b/scripts/host/check_requirements.sh index 75f8560e7ce..c9a950474c0 100755 --- a/scripts/host/check_requirements.sh +++ b/scripts/host/check_requirements.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd) -composer_auth_json="${vagrant_dir}/etc/composer/auth.json" php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error diff --git a/scripts/host/composer.sh b/scripts/host/composer.sh index aa43946de5f..7897c75f22d 100755 --- a/scripts/host/composer.sh +++ b/scripts/host/composer.sh @@ -23,7 +23,9 @@ fi # Configure composer credentials cd ${current_dir} -cp ${composer_auth_json} "${PWD}/auth.json" +if [ -f ${composer_auth_json} ]; then + cp ${composer_auth_json} "${PWD}/auth.json" +fi host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") if [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_composer_prefer_source") == 1 ]]; then @@ -32,4 +34,7 @@ if [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_composer_ else ${php_executable} ${composer_phar} --ignore-platform-reqs "$@" fi -rm "${PWD}/auth.json" + +if [ -f "${PWD}/auth.json" ]; then + rm "${PWD}/auth.json" +fi diff --git a/scripts/host/configure_php_storm.sh b/scripts/host/configure_php_storm.sh index 747d8385226..8643e0824b4 100755 --- a/scripts/host/configure_php_storm.sh +++ b/scripts/host/configure_php_storm.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd) -composer_auth_json="${vagrant_dir}/etc/composer/auth.json" # Enable trace printing and exit on the first error set +x From 0571349003a9bec97ae14d77d0c8ff510a41322b Mon Sep 17 00:00:00 2001 From: Igor Melnikov Date: Fri, 8 Apr 2016 23:54:25 -0500 Subject: [PATCH 014/173] Remove GitHub token requirement Check if auth.json exists before copying --- scripts/provision/configure_environment.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index a65e63dd776..01c4de8a058 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -65,7 +65,9 @@ if [ -f ${composer_auth_json} ]; then if [ ! -d /home/vagrant/.composer ] ; then sudo -H -u vagrant bash -c 'mkdir /home/vagrant/.composer' fi - cp ${composer_auth_json} /home/vagrant/.composer/auth.json + if [ -f ${composer_auth_json} ]; then + cp ${composer_auth_json} /home/vagrant/.composer/auth.json + fi fi # Declare path to scripts supplied with vagrant and Magento From b5a4a60569d129c5db5529e4d81fb8837b234cfb Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 11 Apr 2016 12:06:40 -0500 Subject: [PATCH 015/173] Refined documentation --- CHANGELOG.md | 4 ++++ README.md | 36 ++++++++++++++++++++++++++---------- scripts/guest/m-reinstall | 2 ++ scripts/host/install_php.sh | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 429c3e05f3e..cf42b0b7dd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed + + - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) + ### Fixed - Fixed permissions during Magento installation on Windows hosts diff --git a/README.md b/README.md index b9bf71dfc14..8d098d89a48 100755 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ * [Installation steps](#installation-steps) * [Default credentials and settings](#default-credentials-and-settings) * [Getting updates and fixes](#getting-updates-and-fixes) + * [Troubleshooting](#troubleshooting) * [Day-to-day development scenarios](#day-to-day-development-scenarios) * [Reinstall Magento](#reinstall-magento) * [Clear magento cache](#clear-magento-cache) @@ -61,6 +62,8 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik - ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) [NFS server](https://en.wikipedia.org/wiki/Network_File_System) must be installed and running on \*nix and OSX hosts. Is usually available, so just try to follow [installation steps](#how-to-install) first. ### Installation steps + +:information_source: In case of any issues during installation, please read [troubleshooting section](#troubleshooting) 1. Open terminal and change directory to the one which you want to contain Magento project. ![](docs/images/windows-icon.png) On Windows use Git Bash, which is available after Git installation @@ -78,15 +81,12 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik 1. Optionally, copy [etc/config.yaml.dist](etc/config.yaml.dist) as `etc/config.yaml` and make necessary customizations - 1. Initialize project, configure environment, install Magento, configure PHPStorm project: + 1. Initialize project (this will configure environment, install Magento, configure PHPStorm project): ``` cd vagrant-magento bash init_project.sh ``` - - :information_source: ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) On OSX and \*nix hosts NFS will be used by default to sync your project files with guest. On some hosts Vagrant cannot configure NFS properly, in this case it is possible to deploy project without NFS by setting `use_nfs` option in [config.yaml](etc/config.yaml.dist) to `0`
- :information_source: ![](docs/images/windows-icon.png) On Windows hosts you might face `Composer Install Error: ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)` exception during `composer install`. This can be fixed in 2 ways: decrease path length to the project directory or set `composer_prefer_source` option in [config.yaml](etc/config.yaml.dist) to `1` 1. Use `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`). This is important, because in this case PHP Storm will be configured automatically by [init_project.sh](init_project.sh). If NFS files sync is disabled in [config](etc/config.yaml.dist) and ![](docs/images/windows-icon.png) on Windows hosts [verify deployment configuration in PHP Storm](docs/phpstorm-configuration-windows-hosts.md) @@ -124,6 +124,14 @@ Current vagrant project follows [semantic versioning](http://semver.org/spec/v2. For example your current branch is `2.0`, then it will be safe to pull any changes from `origin/2.0`. However branch `3.0` will contain changes backward incompatible with `2.0`. Note, that semantic versioning is only used for `x.0` branches (not for `develop`). +### Troubleshooting + + 1. ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) On OSX and \*nix hosts NFS will be used by default to sync your project files with guest. On some hosts Vagrant cannot configure NFS properly, in this case it is possible to deploy project without NFS by setting `use_nfs` option in [config.yaml](etc/config.yaml.dist) to `0`
+ 1. ![](docs/images/windows-icon.png) On Windows hosts you might face `Composer Install Error: ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)` exception during `composer install`. This can be fixed in 2 ways: decrease path length to the project directory or set `composer_prefer_source` option in [config.yaml](etc/config.yaml.dist) to `1` + 1. Make sure that you used `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`) + 1. If code is not synchronized properly on Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly), make sure that PhpStorm is running before making any changes in the code. This is important because otherwise PhpStorm will not be able to detect changes and upload them to the guest machine + 1. Please make sure that currently installed software, specified in [requirements section](#requirements), meets minimum version requirement + ## Day-to-day development scenarios ### Reinstall Magento @@ -155,11 +163,7 @@ bash m-switch-to-ce OR bash m-switch-to-ee ``` -:information_source: ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) On OSX and \*nix hosts without NFS -you will be asked to wait until uploading process in PhpStorm is finished(PhpStorm should be lunched). To continue the process you need to press any key. -process is finished. To continue the process you need to press any key. -:information_source: ![](docs/images/windows-icon.png) On Windows hosts you will be asked to wait until uploading -process in PhpStorm is finished(PhpStorm should be lunched). To continue the process you need to press any key. +:information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key. ### Update composer dependencies @@ -188,7 +192,19 @@ XDebug is already configured to connect to the host machine automatically. So ju 1. Set XDEBUG_SESSION=1 cookie (e.g. using 'easy Xdebug' extension for Firefox). See [XDebug documentation](http://xdebug.org/docs/remote) for more details 1. Start listening for PHP Debug connections in PhpStorm on default 9000 port. See how to [integrate XDebug with PhpStorm](https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html#integrationWithProduct) 1. Set beakpoint or set option in PhpStorm menu 'Run -> Break at first line in PHP scripts' - + +To debug a CLI script: + + 1. Create [remote debug configuration](https://www.jetbrains.com/help/phpstorm/2016.1/run-debug-configuration-php-remote-debug.html) in PhpStorm, use `PHPSTORM` as IDE key + 1. Run created remote debug configuration + 1. Run CLI command on the guest as follows (`xdebug.remote_host` value might be different for you): + + ``` + php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 + ``` + +To debug Magento Setup script, go to [Magento installation script](scripts/guest/m-reinstall) and find `php ${install_cmd}`. Follow steps above for any CLI script + ### Connecting to MySQL DB Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-developers/issues/8) diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 4a3b85817cc..d9ae401fd93 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -72,6 +72,8 @@ fi chmod +x bin/magento php ${install_cmd} +# Comment out the line above and uncomment the one below to debug Magento Setup script +# php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - diff --git a/scripts/host/install_php.sh b/scripts/host/install_php.sh index 02606393830..90918caa0a7 100755 --- a/scripts/host/install_php.sh +++ b/scripts/host/install_php.sh @@ -7,7 +7,7 @@ host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") set -ex if [[ ${host_os} == "Windows" ]]; then - curl http://windows.php.net/downloads/releases/archives/php-7.0.2-nts-Win32-VC14-x86.zip -o ${vagrant_dir}/lib/php.zip + curl http://windows.php.net/downloads/releases/archives/php-5.6.9-nts-Win32-VC11-x86.zip -o ${vagrant_dir}/lib/php.zip unzip -q ${vagrant_dir}/lib/php.zip -d ${vagrant_dir}/lib/php rm -f ${vagrant_dir}/lib/php.zip cp "${vagrant_dir}/lib/php/php.ini-development" "${vagrant_dir}/lib/php/php.ini" From 563786725eef97c32d6e628abf646dd9d34c1691 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 13 Apr 2016 09:19:42 -0500 Subject: [PATCH 016/173] Added section to README.md about Environment reset --- README.md | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8d098d89a48..e7bef734ce0 100755 --- a/README.md +++ b/README.md @@ -13,13 +13,14 @@ * [Troubleshooting](#troubleshooting) * [Day-to-day development scenarios](#day-to-day-development-scenarios) * [Reinstall Magento](#reinstall-magento) - * [Clear magento cache](#clear-magento-cache) - * [Update composer dependencies](#update-composer-dependencies) + * [Clear Magento cache](#clear-magento-cache) + * [Update Composer dependencies](#update-composer-dependencies) * [Switch between CE and EE](#switch-between-ce-and-ee) * [Use Magento CLI (bin/magento)](#use-magento-cli-binmagento) * [Debugging with XDebug](#debugging-with-xdebug) * [Connecting to MySQL DB](#connecting-to-mysql-db) * [Multiple Magento instances](#multiple-magento-instances) + * [Reset environment](#reset-environment) ## What You get @@ -64,32 +65,32 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik ### Installation steps :information_source: In case of any issues during installation, please read [troubleshooting section](#troubleshooting) - + 1. Open terminal and change directory to the one which you want to contain Magento project. ![](docs/images/windows-icon.png) On Windows use Git Bash, which is available after Git installation 1. Download project with Vagrant configuration: - + ``` git clone git@github.com:paliarush/magento2-vagrant-for-developers.git vagrant-magento ``` - + 1. Optionally, if you use private repositories on GitHub or download packages from Magento Marketplace - + - copy [etc/composer/auth.json.dist](etc/composer/auth.json.dist) to `etc/composer/auth.json` - specify your GitHub token by adding `"github.com": "your-github-token"` to `github-oauth` section for GitHub authorization - add Magento Marketplace keys for Marketplace authorization 1. Optionally, copy [etc/config.yaml.dist](etc/config.yaml.dist) as `etc/config.yaml` and make necessary customizations - + 1. Initialize project (this will configure environment, install Magento, configure PHPStorm project): - + ``` cd vagrant-magento bash init_project.sh ``` 1. Use `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`). This is important, because in this case PHP Storm will be configured automatically by [init_project.sh](init_project.sh). If NFS files sync is disabled in [config](etc/config.yaml.dist) and ![](docs/images/windows-icon.png) on Windows hosts [verify deployment configuration in PHP Storm](docs/phpstorm-configuration-windows-hosts.md) - + 1. Configure remote PHP interpreter in PHP Storm. Go to `Settings => Languages & Frameworks => PHP`, add new remote interpreter and select "Deployment configuration" as a source for connection details. ### Default credentials and settings @@ -133,7 +134,7 @@ Note, that semantic versioning is only used for `x.0` branches (not for `develop 1. Please make sure that currently installed software, specified in [requirements section](#requirements), meets minimum version requirement ## Day-to-day development scenarios - + ### Reinstall Magento To save some time and get clear Magento installation, you can skip installation of software like web server or php. The following command will clear Magento DB, Magento caches and reinstall Magento instance. @@ -144,7 +145,7 @@ Go to 'vagrant-magento' created earlier and run in command line: bash m-reinstall ``` -### Clear magento cache +### Clear Magento cache Go to 'vagrant-magento' created earlier and run in command line: @@ -165,7 +166,7 @@ bash m-switch-to-ee ``` :information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key. -### Update composer dependencies +### Update Composer dependencies Go to 'vagrant-magento' created earlier and run in command line: @@ -181,14 +182,14 @@ Go to 'vagrant-magento' created earlier and run in command line: ``` bash m-bin-magento -e.g. +e.g. bash m-bin-magento list ``` ### Debugging with XDebug XDebug is already configured to connect to the host machine automatically. So just: - + 1. Set XDEBUG_SESSION=1 cookie (e.g. using 'easy Xdebug' extension for Firefox). See [XDebug documentation](http://xdebug.org/docs/remote) for more details 1. Start listening for PHP Debug connections in PhpStorm on default 9000 port. See how to [integrate XDebug with PhpStorm](https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html#integrationWithProduct) 1. Set beakpoint or set option in PhpStorm menu 'Run -> Break at first line in PHP scripts' @@ -213,3 +214,21 @@ Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-dev To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host. Unique IP address, SSH port and domain name will be generated for each new instance if not specified manually in `etc/config.yaml` + +### Reset environment + +It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box, vagrant project settings and PhpStorm project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) will stay untouched. + +Go to 'vagrant-magento' created earlier and run in command line: + +``` +bash init-project.sh -f +``` + +You can reset project settings and Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in [etc/config.yaml](etc/config.yaml.dist) + +Go to 'vagrant-magento' created earlier and run in command line: + +``` +bash init-project.sh -fc +``` From 38a4db717525b0be8bfb3b5326cd7a751a885e2b Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 18 Apr 2016 11:18:16 -0500 Subject: [PATCH 017/173] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7bef734ce0..8a809daa98d 100755 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ It is possible to reset project environment to default state, which you usually Go to 'vagrant-magento' created earlier and run in command line: ``` -bash init-project.sh -f +bash init_project.sh -f ``` You can reset project settings and Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in [etc/config.yaml](etc/config.yaml.dist) @@ -230,5 +230,5 @@ You can reset project settings and Magento 2 code base at the same time. Magento Go to 'vagrant-magento' created earlier and run in command line: ``` -bash init-project.sh -fc +bash init_project.sh -fc ``` From 26a06d0951c4aa80ee0212d1e2ac9456c45e42c7 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 20 Apr 2016 18:06:10 -0500 Subject: [PATCH 018/173] Sample data usage --- m-reinstall | 12 +++++++++++- m-switch-to-ee | 2 +- scripts/guest/m-reinstall | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/m-reinstall b/m-reinstall index 359d2436c7b..74ddd4cbcd2 100755 --- a/m-reinstall +++ b/m-reinstall @@ -2,6 +2,7 @@ vagrant_dir=$(cd "$(dirname "$0")"; pwd) magento_ce_dir="${vagrant_dir}/magento2ce" +magento_ee_dir="${magento_ce_dir}/magento2ee" magento_ce_sample_data_dir="${magento_ce_dir}/magento2ce-sample-data" magento_ee_sample_data_dir="${magento_ce_dir}/magento2ee-sample-data" php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") @@ -19,6 +20,11 @@ while [ "$1" != "" ]; do shift done +install_ee=0 +if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then + install_ee=1 +fi + # As a precondition, disable CE sample data if [ -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php ]; then ${php_executable} -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php -- --command=unlink --ce-source="${magento_ce_dir}" --sample-data-source="${magento_ce_sample_data_dir}" @@ -34,6 +40,10 @@ if [ -f ${magento_ee_sample_data_dir}/dev/tools/build-sample-data.php ]; then set -x fi +if [ ${install_ee} = 1 ]; then + ${php_executable} -f ${magento_ee_dir}/dev/tools/build-ee.php -- --command=link --ee-source="${magento_ee_dir}" --ce-source="${magento_ce_dir}" +fi + if [ ${with_sample_data} = 1 ]; then # Installing CE or EE, in both cases CE sample data should be linked if [ ! -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php ]; then @@ -50,7 +60,7 @@ if [ ${with_sample_data} = 1 ]; then ${php_executable} -f ${magento_ce_sample_data_dir}/dev/tools/build-sample-data.php -- --command=link --ce-source="${magento_ce_dir}" --sample-data-source="${magento_ce_sample_data_dir}" fi - if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then + if [ ${install_ee} = 1 ]; then # Installing EE if [ ! -f ${magento_ee_sample_data_dir}/dev/tools/build-sample-data.php ]; then # Sample data not available and should be enabled diff --git a/m-switch-to-ee b/m-switch-to-ee index 656b4d9771b..74865c540a7 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -19,7 +19,7 @@ while [ "$1" != "" ]; do shift done -if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then +if [ ! -f ${magento_ee_dir}/dev/tools/build-ee.php ]; then echo "EE codebase is not available" exit 0 fi diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index ca80e18e53f..75aa8871731 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -31,6 +31,11 @@ cd ${MAGENTO_ROOT} # Clear cache m-clear-cache +# Reset Rabbit MQ configuration +sudo rabbitmqctl stop_app +sudo rabbitmqctl reset +sudo rabbitmqctl start_app + # Remove configuration files rm -f "${MAGENTO_ROOT}/app/etc/config.php" rm -f "${MAGENTO_ROOT}/app/etc/env.php" From fd777b91a788559431b71dd38bd5da9a1f1f43a5 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 20 Apr 2016 18:30:26 -0500 Subject: [PATCH 019/173] Improved robustness of EE linking on Windows --- m-switch-to-ce | 3 ++- m-switch-to-ee | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/m-switch-to-ce b/m-switch-to-ce index c564018eac3..04e1c9ae85b 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -30,8 +30,9 @@ if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json fi - if [ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ]; then + if [ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ] && [ ! -L ${magento_ce_dir}/app/etc/enterprise ]; then rm ${magento_ce_dir}/app/etc/enterprise/di.xml + rmdir ${magento_ce_dir}/app/etc/enterprise fi fi diff --git a/m-switch-to-ee b/m-switch-to-ee index 9cedf80fea9..138184642af 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -26,12 +26,13 @@ cp ${magento_ee_dir}/composer.lock ${magento_ce_dir}/composer.lock if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then # Prevent issues on Windows with incorrect symlinks to files - if [ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then + if [ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ] && [ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json cp ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ${magento_ce_dir}/app/etc/aliases_to_classes_map.json fi - if [ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ]; then - rm ${magento_ce_dir}/app/etc/enterprise/di.xml + if [ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ] && [ -L ${magento_ce_dir}/app/etc/enterprise ]; then + rm ${magento_ce_dir}/app/etc/enterprise + mkdir ${magento_ce_dir}/app/etc/enterprise cp ${magento_ee_dir}/app/etc/enterprise/di.xml ${magento_ce_dir}/app/etc/enterprise/di.xml fi fi From 600c8f1bebda86234f82989cbe08dc5ba7f3b171 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Sat, 23 Apr 2016 17:43:18 -0500 Subject: [PATCH 020/173] Added ability to edit guest config files directly from IDE on the host --- CHANGELOG.md | 1 + README.md | 12 +++++++-- Vagrantfile | 9 +++++-- etc/.gitignore | 1 + etc/guest/.gitignore | 1 + init_project.sh | 8 +++++- scripts/guest/link_configs | 27 +++++++++++++++++++ scripts/guest/unlink_configs | 27 +++++++++++++++++++ .../configure_environment_recurring.sh | 10 +++++++ ...s.sh => export_env_variables_recurring.sh} | 0 10 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 etc/guest/.gitignore create mode 100755 scripts/guest/link_configs create mode 100755 scripts/guest/unlink_configs create mode 100755 scripts/provision/configure_environment_recurring.sh rename scripts/provision/{export_env_variables.sh => export_env_variables_recurring.sh} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf42b0b7dd1..06c65078fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Added host wrapper script for bin/magento command on guest + - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE ## [v2.0.0] - 2016-02-05 diff --git a/README.md b/README.md index 8a809daa98d..a7b264f452c 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ * [Use Magento CLI (bin/magento)](#use-magento-cli-binmagento) * [Debugging with XDebug](#debugging-with-xdebug) * [Connecting to MySQL DB](#connecting-to-mysql-db) + * [Accessing PHP and other config files](#accessing-php-and-other-config-files) * [Multiple Magento instances](#multiple-magento-instances) * [Reset environment](#reset-environment) @@ -210,14 +211,21 @@ To debug Magento Setup script, go to [Magento installation script](scripts/guest Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-developers/issues/8) +### Accessing PHP and other config files + +It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes, but not limited to: PHP, Apache, Mysql, Varnish, RabbitMQ, hosts, cron. +Do not edit any symlinks using PhpStorm because it may break your installation. + +After editing configs in IDE it is still required to restart related services manually. + ### Multiple Magento instances - + To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host. Unique IP address, SSH port and domain name will be generated for each new instance if not specified manually in `etc/config.yaml` ### Reset environment -It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box, vagrant project settings and PhpStorm project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) will stay untouched. +It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box, vagrant project settings and PhpStorm project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) and [etc/config.yaml](etc/config.yaml.dist) will stay untouched, but guest config files (located in [etc/guest](etc/guest)) will be removed. Go to 'vagrant-magento' created earlier and run in command line: diff --git a/Vagrantfile b/Vagrantfile index ec3d37febf1..8689c7ad0d8 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -72,8 +72,13 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| s.args = shell_script_args end - config.vm.provision "export_env_variables", type: "shell", run: "always" do |s| - s.path = "scripts/provision/export_env_variables.sh" + config.vm.provision "configure_environment_recurring", type: "shell", run: "always" do |s| + s.path = "scripts/provision/configure_environment_recurring.sh" + s.args = shell_script_args + end + + config.vm.provision "export_env_variables_recurring", type: "shell", run: "always" do |s| + s.path = "scripts/provision/export_env_variables_recurring.sh" s.args = shell_script_args end diff --git a/etc/.gitignore b/etc/.gitignore index c62aab67d1f..44c9e13080d 100644 --- a/etc/.gitignore +++ b/etc/.gitignore @@ -5,3 +5,4 @@ !/composer/auth.json.dist !/config.yaml.dist !/magento2_virtual_host.conf.dist +!/guest \ No newline at end of file diff --git a/etc/guest/.gitignore b/etc/guest/.gitignore new file mode 100644 index 00000000000..22e83649f7d --- /dev/null +++ b/etc/guest/.gitignore @@ -0,0 +1 @@ +/* \ No newline at end of file diff --git a/init_project.sh b/init_project.sh index ba225a25f76..6d8f99dd36b 100755 --- a/init_project.sh +++ b/init_project.sh @@ -46,7 +46,10 @@ while getopts 'fc' flag; do done if [ ${force_project_cleaning} -eq 1 ]; then vagrant destroy -f - rm -rf ${vagrant_dir}/.idea ${vagrant_dir}/.vagrant + mv ${vagrant_dir}/etc/guest/.gitignore ${vagrant_dir}/etc/.gitignore.back + rm -rf ${vagrant_dir}/.vagrant ${vagrant_dir}/etc/guest + mkdir ${vagrant_dir}/etc/guest + mv ${vagrant_dir}/etc/.gitignore.back ${vagrant_dir}/etc/guest/.gitignore if [ ${force_codebase_cleaning} -eq 1 ]; then rm -rf ${magento_ce_dir} fi @@ -77,4 +80,7 @@ bash "${vagrant_dir}/scripts/host/composer.sh" install cd ${vagrant_dir} vagrant up +if [ ${force_project_cleaning} -eq 1 ]; then + rm -rf ${vagrant_dir}/.idea/* +fi bash "${vagrant_dir}/scripts/host/configure_php_storm.sh" diff --git a/scripts/guest/link_configs b/scripts/guest/link_configs new file mode 100755 index 00000000000..25dd244a8a6 --- /dev/null +++ b/scripts/guest/link_configs @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# See unlink_configs script + +# Enable trace printing and exit on the first error +set -ex + +# Make guest configs visible and editable in the host IDE + +# Configs located under /etc/* +configs=( apache2 php mysql varnish rabbitmq init.d crontab cron.d timezone hosts ) +for config in "${configs[@]}" +do + if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then + mv /etc/${config} /vagrant/etc/guest/${config} + ln -s /vagrant/etc/guest/${config} /etc/${config} + fi +done + +# Configs located under ~/* +configs=( .bashrc .composer .profile ) +for config in "${configs[@]}" +do + if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then + mv /home/vagrant/${config} /vagrant/etc/guest/${config} + ln -s /vagrant/etc/guest/${config} /home/vagrant/${config} + fi +done \ No newline at end of file diff --git a/scripts/guest/unlink_configs b/scripts/guest/unlink_configs new file mode 100755 index 00000000000..426976e35a6 --- /dev/null +++ b/scripts/guest/unlink_configs @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# See link_configs script + +# Enable trace printing and exit on the first error +set -ex + +# Revert configs before shutdown or reboot to allow proper services initialization on booting + +# Configs located under /etc/* +configs=( apache2 php mysql varnish rabbitmq init.d crontab cron.d timezone hosts ) +for config in "${configs[@]}" +do + if [ -L /etc/${config} ]; then + sudo rm /etc/${config} + sudo mv /vagrant/etc/guest/${config} /etc/${config} + fi +done + +# Configs located under ~/* +configs=( .bashrc .composer .profile ) +for config in "${configs[@]}" +do + if [ -L /home/vagrant/${config} ]; then + sudo rm /home/vagrant/${config} + sudo mv /vagrant/etc/guest/${config} /home/vagrant/${config} + fi +done \ No newline at end of file diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh new file mode 100755 index 00000000000..73ded29d118 --- /dev/null +++ b/scripts/provision/configure_environment_recurring.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +link_configs + +# Make sure configs are restored on system halt and during reboot +if [ ! -f /etc/init.d/K04-unlink-configs ]; then + ln -s /vagrant/scripts/guest/unlink_configs /etc/init.d/K04-unlink-configs + ln -s /etc/init.d/K04-unlink-configs /etc/rc0.d/K04-unlink-configs + ln -s /etc/init.d/K04-unlink-configs /etc/rc6.d/K04-unlink-configs +fi \ No newline at end of file diff --git a/scripts/provision/export_env_variables.sh b/scripts/provision/export_env_variables_recurring.sh similarity index 100% rename from scripts/provision/export_env_variables.sh rename to scripts/provision/export_env_variables_recurring.sh From 3e260f7c5ad423f747e2944fe9f592787c96b8f4 Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Mon, 25 Apr 2016 13:14:26 -0500 Subject: [PATCH 021/173] Added option for virtualhost of amqp --- scripts/guest/m-reinstall | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index d9ae401fd93..181e3cf6a9d 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -25,6 +25,7 @@ setupOptions[amqp_host]='localhost' setupOptions[amqp_port]='5672' setupOptions[amqp_user]='guest' setupOptions[amqp_password]='guest' +setupOptions[amqp_virtualhost]='/' cd ${MAGENTO_ROOT} @@ -67,6 +68,7 @@ if [ -f "${MAGENTO_ROOT}/app/code/Magento/Amqp/registration.php" ]; then --amqp-host=${setupOptions[amqp_host]} \ --amqp-port=${setupOptions[amqp_port]} \ --amqp-user=${setupOptions[amqp_user]} \ + --amqp-virtualhost=${setupOptions[amqp_virtualhost]} \ --amqp-password=${setupOptions[amqp_password]}" fi From 3d3b77dfae42c1083c446b410f70c8dc1a63c2c9 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Tue, 26 Apr 2016 12:11:37 -0500 Subject: [PATCH 022/173] - Changed requirements for minimum box version from 1.0 to 1.1 - Fixed issue with Magento compiler on Windows hosts --- CHANGELOG.md | 2 ++ Vagrantfile | 4 ++-- docs/phpstorm-configuration-windows-hosts.md | 2 +- scripts/host/php-storm-configs/deployment.xml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c65078fa7..ae87dd1caf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) + - Changed requirement for minimum box version from 1.0 to 1.1 ### Fixed - Fixed permissions during Magento installation on Windows hosts + - Fixed issue with Magento compiler on Windows hosts ### Added diff --git a/Vagrantfile b/Vagrantfile index 8689c7ad0d8..06babe6765c 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -39,7 +39,7 @@ host_magento_dir = Dir.pwd + '/magento2ce' VAGRANT_API_VERSION = 2 Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.box = "paliarush/magento2.ubuntu" - config.vm.box_version = "~> 1.0" + config.vm.box_version = "~> 1.1" config.vm.provider "virtualbox" do |vb| vb.memory = guest_memory @@ -54,7 +54,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.synced_folder host_magento_dir, guest_magento_dir, type: "nfs", create: true else guest_magento_dir = '/var/www/magento2ce' - config.vm.synced_folder host_magento_dir + '/var/generation', guest_magento_dir + '/var/generation', create: true + config.vm.synced_folder host_magento_dir + '/var', guest_magento_dir + '/var', create: true config.vm.synced_folder host_magento_dir + '/app/etc', guest_magento_dir + '/app/etc', create: true end diff --git a/docs/phpstorm-configuration-windows-hosts.md b/docs/phpstorm-configuration-windows-hosts.md index 29b252dfc95..de4e6fed083 100644 --- a/docs/phpstorm-configuration-windows-hosts.md +++ b/docs/phpstorm-configuration-windows-hosts.md @@ -7,7 +7,7 @@ This solution is applicable to any Vagrant configuration for Magento instance, s ``` Vagrant.configure(2) do |config| - config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2ce/var/generation' + config.vm.synced_folder '../magento2ce/var', '/var/www/magento2ce/var' config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2ce/app/etc' end ``` diff --git a/scripts/host/php-storm-configs/deployment.xml b/scripts/host/php-storm-configs/deployment.xml index 068e9bcf8c8..2e42b911e78 100644 --- a/scripts/host/php-storm-configs/deployment.xml +++ b/scripts/host/php-storm-configs/deployment.xml @@ -9,7 +9,7 @@ - + From 1409e548f47e1238a214b15d3ebfb9b92fa32dd6 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Tue, 26 Apr 2016 12:11:37 -0500 Subject: [PATCH 023/173] - Changed requirements for minimum box version from 1.0 to 1.1 - Fixed issue with Magento compiler on Windows hosts --- CHANGELOG.md | 2 ++ Vagrantfile | 4 ++-- docs/phpstorm-configuration-windows-hosts.md | 2 +- scripts/host/php-storm-configs/deployment.xml | 2 +- scripts/provision/configure_environment_recurring.sh | 8 ++++++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c65078fa7..ae87dd1caf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) + - Changed requirement for minimum box version from 1.0 to 1.1 ### Fixed - Fixed permissions during Magento installation on Windows hosts + - Fixed issue with Magento compiler on Windows hosts ### Added diff --git a/Vagrantfile b/Vagrantfile index 8689c7ad0d8..06babe6765c 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -39,7 +39,7 @@ host_magento_dir = Dir.pwd + '/magento2ce' VAGRANT_API_VERSION = 2 Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.box = "paliarush/magento2.ubuntu" - config.vm.box_version = "~> 1.0" + config.vm.box_version = "~> 1.1" config.vm.provider "virtualbox" do |vb| vb.memory = guest_memory @@ -54,7 +54,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.synced_folder host_magento_dir, guest_magento_dir, type: "nfs", create: true else guest_magento_dir = '/var/www/magento2ce' - config.vm.synced_folder host_magento_dir + '/var/generation', guest_magento_dir + '/var/generation', create: true + config.vm.synced_folder host_magento_dir + '/var', guest_magento_dir + '/var', create: true config.vm.synced_folder host_magento_dir + '/app/etc', guest_magento_dir + '/app/etc', create: true end diff --git a/docs/phpstorm-configuration-windows-hosts.md b/docs/phpstorm-configuration-windows-hosts.md index 29b252dfc95..de4e6fed083 100644 --- a/docs/phpstorm-configuration-windows-hosts.md +++ b/docs/phpstorm-configuration-windows-hosts.md @@ -7,7 +7,7 @@ This solution is applicable to any Vagrant configuration for Magento instance, s ``` Vagrant.configure(2) do |config| - config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2ce/var/generation' + config.vm.synced_folder '../magento2ce/var', '/var/www/magento2ce/var' config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2ce/app/etc' end ``` diff --git a/scripts/host/php-storm-configs/deployment.xml b/scripts/host/php-storm-configs/deployment.xml index 068e9bcf8c8..2e42b911e78 100644 --- a/scripts/host/php-storm-configs/deployment.xml +++ b/scripts/host/php-storm-configs/deployment.xml @@ -9,7 +9,7 @@ - + diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 73ded29d118..5bb5bb43de5 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Enable trace printing and exit on the first error +set +x + link_configs # Make sure configs are restored on system halt and during reboot @@ -7,4 +10,9 @@ if [ ! -f /etc/init.d/K04-unlink-configs ]; then ln -s /vagrant/scripts/guest/unlink_configs /etc/init.d/K04-unlink-configs ln -s /etc/init.d/K04-unlink-configs /etc/rc0.d/K04-unlink-configs ln -s /etc/init.d/K04-unlink-configs /etc/rc6.d/K04-unlink-configs +fi + +# Upgrade existing environment +if [ -f /vagrant/.idea/deployment.xml ]; then + sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "/vagrant/.idea/deployment.xml" fi \ No newline at end of file From 7abac21e5fa97a7951c07c62970e551b8cb2a377 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 27 Apr 2016 17:29:35 -0500 Subject: [PATCH 024/173] - Improved developer experience during project initialization - Fixed recurring environment variables export - Optimized cache clearing script --- Vagrantfile | 6 ++++-- init_project.sh | 17 +++++++++++++++++ scripts/guest/link_configs | 14 +++++++++----- scripts/guest/m-clear-cache | 10 ++++------ scripts/guest/m-reinstall | 13 ++----------- scripts/provision/configure_environment.sh | 6 ------ .../export_env_variables_recurring.sh | 19 ++++++++++++++++--- 7 files changed, 52 insertions(+), 33 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 06babe6765c..bad62452dff 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -34,7 +34,8 @@ guest_memory = config_data['guest']['memory'] # NFS will be used for *nix and OSX hosts, if not disabled explicitly in config use_nfs_for_synced_folders = !OS.is_windows && (config_data['guest']['use_nfs'] == 1) -host_magento_dir = Dir.pwd + '/magento2ce' +host_vagrant_dir = Dir.pwd + '' +host_magento_dir = host_vagrant_dir + '/magento2ce' VAGRANT_API_VERSION = 2 Vagrant.configure(VAGRANT_API_VERSION) do |config| @@ -64,7 +65,8 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| magento_host_name, #3 config_data['environment']['use_php7'], #4 host_magento_dir, #5 - OS.is_windows ? "1" : "0" #6 + OS.is_windows ? "1" : "0", #6 + host_vagrant_dir #7 ] config.vm.provision "configure_environment", type: "shell" do |s| diff --git a/init_project.sh b/init_project.sh index 6d8f99dd36b..4668a1a50ab 100755 --- a/init_project.sh +++ b/init_project.sh @@ -80,7 +80,24 @@ bash "${vagrant_dir}/scripts/host/composer.sh" install cd ${vagrant_dir} vagrant up +set +x +echo "Configuring PhpStorm..." if [ ${force_project_cleaning} -eq 1 ]; then rm -rf ${vagrant_dir}/.idea/* fi bash "${vagrant_dir}/scripts/host/configure_php_storm.sh" + +bold=$(tput bold) +regular=$(tput sgr0) +echo " +${bold}[Important]${regular} + Please use ${bold}${vagrant_dir}${regular} directory as PhpStorm project root, NOT ${bold}${magento_ce_dir}${regular}." + +use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") +if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then + echo " +${bold}[Optional]${regular} + To verify that deployment configuration for ${bold}${magento_ce_dir}${regular} in PhpStorm is correct, + use instructions provided here: ${bold}https://github.com/paliarush/magento2-vagrant-for-developers/blob/2.0/docs/phpstorm-configuration-windows-hosts.md${regular}. + If not using PhpStorm, you can set up synchronization using rsync" +fi diff --git a/scripts/guest/link_configs b/scripts/guest/link_configs index 25dd244a8a6..a2b332bdee6 100755 --- a/scripts/guest/link_configs +++ b/scripts/guest/link_configs @@ -7,12 +7,14 @@ set -ex # Make guest configs visible and editable in the host IDE # Configs located under /etc/* -configs=( apache2 php mysql varnish rabbitmq init.d crontab cron.d timezone hosts ) +configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d ) for config in "${configs[@]}" do if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then - mv /etc/${config} /vagrant/etc/guest/${config} - ln -s /vagrant/etc/guest/${config} /etc/${config} + if [ -d /etc/${config} ] || [ -f /etc/${config} ]; then + mv /etc/${config} /vagrant/etc/guest/${config} + ln -s /vagrant/etc/guest/${config} /etc/${config} + fi fi done @@ -21,7 +23,9 @@ configs=( .bashrc .composer .profile ) for config in "${configs[@]}" do if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then - mv /home/vagrant/${config} /vagrant/etc/guest/${config} - ln -s /vagrant/etc/guest/${config} /home/vagrant/${config} + if [ -d /home/vagrant/${config} ] || [ -f /home/vagrant/${config} ]; then + mv /home/vagrant/${config} /vagrant/etc/guest/${config} + ln -s /vagrant/etc/guest/${config} /home/vagrant/${config} + fi fi done \ No newline at end of file diff --git a/scripts/guest/m-clear-cache b/scripts/guest/m-clear-cache index a50f224a2a7..bfc896e58f5 100755 --- a/scripts/guest/m-clear-cache +++ b/scripts/guest/m-clear-cache @@ -4,14 +4,12 @@ echo "Clearing Magento cache..." rm -f ${MAGENTO_ROOT}/app/etc/paths.php #clear var -for dir in `ls ${MAGENTO_ROOT}/var` ; do - rm -rf ${MAGENTO_ROOT}/var/${dir}/* ; -done +cd ${MAGENTO_ROOT} && mv var/.htaccess var_htaccess.back && rm -rf var/* var/.[^.]* && mv var_htaccess.back var/.htaccess #clear pub/statics -cd ${MAGENTO_ROOT}/pub && mv static/.htaccess static_htaccess.back && rm -rf static/* && mv static_htaccess.back static/.htaccess +cd ${MAGENTO_ROOT}/pub && mv static/.htaccess static_htaccess.back && rm -rf static && mkdir static && mv static_htaccess.back static/.htaccess #clear integration tests tmp -cd ${MAGENTO_ROOT}/dev/tests/integration && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp/* && mv tmp_gitignore.back tmp/.gitignore +cd ${MAGENTO_ROOT}/dev/tests/integration && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore #clear unit tests tmp -cd ${MAGENTO_ROOT}/dev/tests/unit && rm -rf tmp/* +cd ${MAGENTO_ROOT}/dev/tests/unit && rm -rf tmp && mkdir tmp echo "Magento cache cleared." diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 181e3cf6a9d..73713e402df 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -63,7 +63,7 @@ install_cmd="./bin/magento setup:install \ --use-rewrites=1" # Configure Rabbit MQ -if [ -f "${MAGENTO_ROOT}/app/code/Magento/Amqp/registration.php" ]; then +if [ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ] && [ -d "${MAGENTO_ROOT}/app/code/Magento/Amqp" ]; then install_cmd="${install_cmd} \ --amqp-host=${setupOptions[amqp_host]} \ --amqp-port=${setupOptions[amqp_port]} \ @@ -93,15 +93,6 @@ sed -i "s|${MAGENTO_ROOT}|${MAGENTO_ROOT_HOST}|g" "/vagrant/.idea/misc.xml" set +x echo " Magento application was deployed to ${MAGENTO_ROOT} and installed successfully + Access storefront at ${setupOptions[base_url]} Access admin panel at ${setupOptions[base_url]}${setupOptions[admin_frontname]}/" - -if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then - echo " - [Optional] To finish developer environment set up: - 1. Please create new PhpStorm project using 'magento2ce' directory on your host - (this directory should already contain Magento repository cloned earlier) - - 2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/2.0/docs/phpstorm-configuration-windows-hosts.md - to set up synchronization in PhpStorm (or using rsync) with ${MAGENTO_ROOT} directory" -fi diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index 01c4de8a058..5f4c0a2567d 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -70,12 +70,6 @@ if [ -f ${composer_auth_json} ]; then fi fi -# Declare path to scripts supplied with vagrant and Magento -echo "export PATH=\$PATH:${vagrant_dir}/scripts/guest:${guest_magento_dir}/bin" >> /etc/profile -echo "export MAGENTO_ROOT=${guest_magento_dir}" >> /etc/profile -echo "export MAGENTO_ROOT_HOST=${host_magento_dir}" >> /etc/profile -echo "export IS_WINDOWS_HOST=${is_windows_host}" >> /etc/profile - # Set permissions to allow Magento codebase upload by Vagrant provision script if [ ${use_nfs_for_synced_folders} -eq 0 ]; then chown -R vagrant:vagrant /var/www diff --git a/scripts/provision/export_env_variables_recurring.sh b/scripts/provision/export_env_variables_recurring.sh index c7e0eee3138..8c94a8e76f5 100755 --- a/scripts/provision/export_env_variables_recurring.sh +++ b/scripts/provision/export_env_variables_recurring.sh @@ -6,7 +6,20 @@ set -e guest_magento_dir=$2 host_magento_dir=$5 is_windows_host=$6 +host_vagrant_dir=$7 +vagrant_dir="/vagrant" -export MAGENTO_ROOT=${guest_magento_dir} -export MAGENTO_ROOT_HOST=${host_magento_dir} -export IS_WINDOWS_HOST=${is_windows_host} +if ! cat /etc/profile | grep -q 'export PATH=' ; then + echo "export PATH=\$PATH:${vagrant_dir}/scripts/guest:${guest_magento_dir}/bin" >> /etc/profile +fi + +if ! cat /etc/profile | grep -q 'export MAGENTO_ROOT=' ; then + echo "export MAGENTO_ROOT=${guest_magento_dir}" >> /etc/profile + echo "export MAGENTO_ROOT_HOST=${host_magento_dir}" >> /etc/profile + echo "export IS_WINDOWS_HOST=${is_windows_host}" >> /etc/profile +fi + +if ! cat /etc/profile | grep -q 'export VAGRANT_ROOT=' ; then + echo "export VAGRANT_ROOT=${vagrant_dir}" >> /etc/profile + echo "export VAGRANT_ROOT_HOST=${host_vagrant_dir}" >> /etc/profile +fi From 7446aeec879af09636c2b7a1dedbd75d33126e73 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Tue, 3 May 2016 18:01:03 -0500 Subject: [PATCH 025/173] Guest configs editable from IDE (https://github.com/paliarush/magento2-vagrant-for-developers/issues/29) --- scripts/guest/link_configs | 40 ++++++++++--------- scripts/guest/unlink_configs | 37 +++++++++-------- .../configure_environment_recurring.sh | 24 +++++++---- 3 files changed, 59 insertions(+), 42 deletions(-) diff --git a/scripts/guest/link_configs b/scripts/guest/link_configs index a2b332bdee6..de6d2c34916 100755 --- a/scripts/guest/link_configs +++ b/scripts/guest/link_configs @@ -1,5 +1,20 @@ #!/usr/bin/env bash -# See unlink_configs script + +function process_configs () { + configs_path=$1 + configs=$2 + for config in "${configs[@]}" + do + if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then + if [ -d ${configs_path}/${config} ] || [ -f ${configs_path}/${config} ]; then + sudo rm -rf "${configs_path}/${config}.back" + sudo cp -rp ${configs_path}/${config} "${configs_path}/${config}.back" + sudo mv ${configs_path}/${config} /vagrant/etc/guest/${config} + sudo ln -s /vagrant/etc/guest/${config} ${configs_path}/${config} + fi + fi + done +} # Enable trace printing and exit on the first error set -ex @@ -7,25 +22,12 @@ set -ex # Make guest configs visible and editable in the host IDE # Configs located under /etc/* +config_dir="/etc" +# See unlink_configs script configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d ) -for config in "${configs[@]}" -do - if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then - if [ -d /etc/${config} ] || [ -f /etc/${config} ]; then - mv /etc/${config} /vagrant/etc/guest/${config} - ln -s /vagrant/etc/guest/${config} /etc/${config} - fi - fi -done +process_configs ${config_dir} ${configs} # Configs located under ~/* +config_dir="/home/vagrant" configs=( .bashrc .composer .profile ) -for config in "${configs[@]}" -do - if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then - if [ -d /home/vagrant/${config} ] || [ -f /home/vagrant/${config} ]; then - mv /home/vagrant/${config} /vagrant/etc/guest/${config} - ln -s /vagrant/etc/guest/${config} /home/vagrant/${config} - fi - fi -done \ No newline at end of file +process_configs ${config_dir} ${configs} \ No newline at end of file diff --git a/scripts/guest/unlink_configs b/scripts/guest/unlink_configs index 426976e35a6..bf706f0e85e 100755 --- a/scripts/guest/unlink_configs +++ b/scripts/guest/unlink_configs @@ -1,5 +1,19 @@ #!/usr/bin/env bash -# See link_configs script + +function process_configs () { + configs_path=$1 + configs=$2 + for config in "${configs[@]}" + do + if [ -L ${config_dir}/${config} ] && [ -e ${config_dir}/${config} ]; then + sudo rm ${config_dir}/${config} + sudo mv /vagrant/etc/guest/${config} ${config_dir}/${config} + elif [ ! -e ${config_dir}/${config} ] && [ -e "${config_dir}/${config}.back" ]; then + sudo rm -rf ${config_dir}/${config} + sudo cp -rp "${config_dir}/${config}.back" ${config_dir}/${config} + fi + done +} # Enable trace printing and exit on the first error set -ex @@ -7,21 +21,12 @@ set -ex # Revert configs before shutdown or reboot to allow proper services initialization on booting # Configs located under /etc/* -configs=( apache2 php mysql varnish rabbitmq init.d crontab cron.d timezone hosts ) -for config in "${configs[@]}" -do - if [ -L /etc/${config} ]; then - sudo rm /etc/${config} - sudo mv /vagrant/etc/guest/${config} /etc/${config} - fi -done +config_dir="/etc" +# See link_configs script +configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d ) +process_configs ${config_dir} ${configs} # Configs located under ~/* +config_dir="/home/vagrant" configs=( .bashrc .composer .profile ) -for config in "${configs[@]}" -do - if [ -L /home/vagrant/${config} ]; then - sudo rm /home/vagrant/${config} - sudo mv /vagrant/etc/guest/${config} /home/vagrant/${config} - fi -done \ No newline at end of file +process_configs ${config_dir} ${configs} diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 5bb5bb43de5..1031d9b41b9 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -3,16 +3,26 @@ # Enable trace printing and exit on the first error set +x -link_configs +vagrant_dir="/vagrant" + +# Remove configs from host in case of force stop of virtual machine before linking restored ones +cd ${vagrant_dir}/etc && mv guest/.gitignore guest_gitignore.back && rm -rf guest && mkdir guest && mv guest_gitignore.back guest/.gitignore +bash ${vagrant_dir}/scripts/guest/link_configs # Make sure configs are restored on system halt and during reboot -if [ ! -f /etc/init.d/K04-unlink-configs ]; then - ln -s /vagrant/scripts/guest/unlink_configs /etc/init.d/K04-unlink-configs - ln -s /etc/init.d/K04-unlink-configs /etc/rc0.d/K04-unlink-configs - ln -s /etc/init.d/K04-unlink-configs /etc/rc6.d/K04-unlink-configs +rm -f /etc/init.d/unlink-configs +cp ${vagrant_dir}/scripts/guest/unlink_configs /etc/init.d/unlink-configs +if [ ! -f /etc/rc0.d/K04-unlink-configs ]; then + ln -s /etc/init.d/unlink-configs /etc/rc0.d/K04-unlink-configs + ln -s /etc/init.d/unlink-configs /etc/rc1.d/S04-unlink-configs + ln -s /etc/init.d/unlink-configs /etc/rc2.d/S04-unlink-configs + ln -s /etc/init.d/unlink-configs /etc/rc3.d/S04-unlink-configs + ln -s /etc/init.d/unlink-configs /etc/rc4.d/S04-unlink-configs + ln -s /etc/init.d/unlink-configs /etc/rc5.d/S04-unlink-configs + ln -s /etc/init.d/unlink-configs /etc/rc6.d/K04-unlink-configs fi # Upgrade existing environment -if [ -f /vagrant/.idea/deployment.xml ]; then - sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "/vagrant/.idea/deployment.xml" +if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then + sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "${vagrant_dir}/.idea/deployment.xml" fi \ No newline at end of file From 67bb8d67a9e65d973faddeaf5edadccf4cdf191a Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Thu, 5 May 2016 18:10:28 -0500 Subject: [PATCH 026/173] Added Varnish support --- etc/config.yaml.dist | 1 + etc/magento2_default_varnish.vcl.dist | 131 ++++++++++++++++++ scripts/guest/m-reinstall | 3 + .../guest/m-reinstall-scripts/config_varnish | 62 +++++++++ scripts/provision/configure_environment.sh | 9 ++ 5 files changed, 206 insertions(+) create mode 100644 etc/magento2_default_varnish.vcl.dist create mode 100644 scripts/guest/m-reinstall-scripts/config_varnish diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index 92dcd23c89c..c911c3c7c98 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -12,6 +12,7 @@ environment: # If set to 0, PHP 5 will be installed use_php7: 1 composer_prefer_source: 0 + use_varnish: 0 magento: host_name: "magento2.vagrant2" admin_frontname: "admin" diff --git a/etc/magento2_default_varnish.vcl.dist b/etc/magento2_default_varnish.vcl.dist new file mode 100644 index 00000000000..103eb94ab1b --- /dev/null +++ b/etc/magento2_default_varnish.vcl.dist @@ -0,0 +1,131 @@ +import std; +# The minimal Varnish version is 3.0.5 + +backend default { + .host = "127.0.0.1"; + .port = "8080"; +} + +acl purge { + "127.0.0.1"; +} + +sub vcl_recv { + if (req.restarts == 0) { + if (req.http.x-forwarded-for) { + set req.http.X-Forwarded-For = + req.http.X-Forwarded-For + ", " + client.ip; + } else { + set req.http.X-Forwarded-For = client.ip; + } + } + + if (req.request == "PURGE") { + if (client.ip !~ purge) { + error 405 "Method not allowed"; + } + if (!req.http.X-Magento-Tags-Pattern) { + error 400 "X-Magento-Tags-Pattern header required"; + } + ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern); + error 200 "Purged"; + } + + if (req.request != "GET" && + req.request != "HEAD" && + req.request != "PUT" && + req.request != "POST" && + req.request != "TRACE" && + req.request != "OPTIONS" && + req.request != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + + # We only deal with GET and HEAD by default + if (req.request != "GET" && req.request != "HEAD") { + return (pass); + } + + # Bypass shopping cart and checkout requests + if (req.url ~ "/checkout") { + return (pass); + } + + # normalize url in case of leading HTTP scheme and domain + set req.url = regsub(req.url, "^http[s]?://", ""); + + # collect all cookies + std.collect(req.http.Cookie); + + # static files are always cacheable. remove SSL flag and cookie + if (req.url ~ "^/(pub/)?(media|static)/.*\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$") { + unset req.http.Https; + unset req.http.Cookie; + } + + set req.grace = 1m; + + return (lookup); +} + +sub vcl_hash { + if (req.http.cookie ~ "X-Magento-Vary=") { + hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1")); + } + +} + +sub vcl_fetch { + if (beresp.http.content-type ~ "text") { + set beresp.do_esi = true; + } + + if (req.url ~ "\.js$" || beresp.http.content-type ~ "text") { + set beresp.do_gzip = true; + } + + # cache only successfully responses and 404s + if (beresp.status != 200 && beresp.status != 404) { + set beresp.ttl = 0s; + return (hit_for_pass); + } elsif (beresp.http.Cache-Control ~ "private") { + return (hit_for_pass); + } + + if (beresp.http.X-Magento-Debug) { + set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control; + } + + # validate if we need to cache it and prevent from setting cookie + # images, css and js are cacheable by default so we have to remove cookie also + if (beresp.ttl > 0s && (req.request == "GET" || req.request == "HEAD")) { + unset beresp.http.set-cookie; + if (req.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") { + set beresp.http.Pragma = "no-cache"; + set beresp.http.Expires = "-1"; + set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0"; + set beresp.grace = 1m; + } + } +} + +sub vcl_deliver { + if (resp.http.X-Magento-Debug) { + if (obj.hits > 0) { + set resp.http.X-Magento-Cache-Debug = "HIT"; + } else { + set resp.http.X-Magento-Cache-Debug = "MISS"; + } + } else { + unset resp.http.Age; + } + + unset resp.http.X-Magento-Debug; + unset resp.http.X-Magento-Tags; + unset resp.http.X-Powered-By; + unset resp.http.Server; + unset resp.http.X-Varnish; + unset resp.http.Via; + unset resp.http.Link; +} diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 73713e402df..c92fc84a3c1 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -77,6 +77,9 @@ php ${install_cmd} # Comment out the line above and uncomment the one below to debug Magento Setup script # php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} +# Configure Varnish FPC, if enabled +sh ${vagrant_dir}/scripts/guest/m-reinstall-scripts/config_varnish + # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - diff --git a/scripts/guest/m-reinstall-scripts/config_varnish b/scripts/guest/m-reinstall-scripts/config_varnish new file mode 100644 index 00000000000..4c34ef9b8de --- /dev/null +++ b/scripts/guest/m-reinstall-scripts/config_varnish @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Enable trace printing and exit on the first error +set -ex + +# Init environment variables +vagrant_dir="/vagrant" + +# Configure Varnish if enabled in config +restart_services=0 +use_varnish=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_use_varnish") +if [ $use_varnish -eq 1 ]; then + + # Configure apache files to be ready for varnish + if [ -z "$(grep "VirtualHost\s\*:8080" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf)" ]; then + sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf + restart_services=1 + fi + if [ -z "$(grep "VirtualHost\s\*:8080" /vagrant/etc/guest/apache2/sites-available/magento2.conf)" ]; then + sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-available/magento2.conf + restart_services=1 + fi + if [ -z "$(grep "Listen\s8080" /vagrant/etc/guest/apache2/ports.conf)" ]; then + sudo sed -ie "s/Listen 80/Listen 8080/" /vagrant/etc/guest/apache2/ports.conf + restart_services=1 + fi + + # Update Magento database to use varnish FPC + mysql -D magento -e "INSERT INTO core_config_data + ( scope, scope_id, path, value ) VALUES + ( 'default', '0', 'system/full_page_cache/caching_application', '2' ) + ;" +else + + # Configure apache files to run without varnish + if [ -z "$(grep "VirtualHost\s\*:80\b" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf)" ]; then + sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf + restart_services=1 + fi + if [ -z "$(grep "VirtualHost\s\*:80\b" /vagrant/etc/guest/apache2/sites-available/magento2.conf)" ]; then + sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-available/magento2.conf + restart_services=1 + fi + if [ -z "$(grep "Listen\s80\b" /vagrant/etc/guest/apache2/ports.conf)" ]; then + sudo sed -ie "s/Listen 8080/Listen 80/" /vagrant/etc/guest/apache2/ports.conf + restart_services=1 + fi +fi + +# Check if need restart services +if [ $restart_services -eq 1 ]; then + if [ "$(ps -ax | pgrep varnish)" ]; then + sudo pkill varnishd + fi + if [ "$(ps -ax | pgrep apache2)" ]; then + sudo apache2ctl stop + fi + sudo apache2ctl start + if [ $use_varnish -eq 1 ]; then + sudo varnishd -f /vagrant/etc/guest/varnish/default.vcl + fi +fi diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index 5f4c0a2567d..2dc6baf586f 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -29,6 +29,15 @@ a2ensite magento2.conf # Disable default virtual host sudo a2dissite 000-default +# Copy varnish vcl file +custom_vcl_config="${vagrant_dir}/etc/magento2_default_varnish.vcl" +default_vcl_config="${vagrant_dir}/etc/magento2_default_varnish.vcl.dist" +if [ -f ${custom_vcl_config} ]; then + cp ${custom_vcl_config} /etc/varnish/default.vcl +else + cp ${default_vcl_config} /etc/varnish/default.vcl +fi + # Setup PHP if [ ${use_php7} -eq 1 ]; then sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" /etc/php/7.0/cli/php.ini From 9eaffb9a232ed8a40406895c644d96c63b6ae478 Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Thu, 5 May 2016 18:10:28 -0500 Subject: [PATCH 027/173] Added Varnish support From 43209b66aea07c42d13d524bc1440f27ede8c136 Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Mon, 9 May 2016 15:01:21 -0500 Subject: [PATCH 028/173] Changed script to look at /etc dir instead of /vagrant/guest/etc/ --- README.md | 2 +- scripts/guest/m-reinstall | 2 +- .../{config_varnish => configure_varnish} | 26 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) rename scripts/guest/m-reinstall-scripts/{config_varnish => configure_varnish} (52%) diff --git a/README.md b/README.md index a7b264f452c..f4e84820471 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ It is easy to [install multiple Magento instances](#multiple-magento-instances) [Project initialization script](init_project.sh) configures complete development environment: 1. Adds some missing software on the host - 1. Configures all software necessary for Magento 2 using [custom Ubuntu vagrant box](https://atlas.hashicorp.com/paliarush/boxes/magento2.ubuntu) (Apache 2.4, PHP 7.0 (or 5.5.9), MySQL 5.6, Git, Composer, XDebug, Rabbit MQ) + 1. Configures all software necessary for Magento 2 using [custom Ubuntu vagrant box](https://atlas.hashicorp.com/paliarush/boxes/magento2.ubuntu) (Apache 2.4, PHP 7.0 (or 5.5.9), MySQL 5.6, Git, Composer, XDebug, Rabbit MQ, Varnish) 1. Installs Magento 2 1. Configures PHP Storm project (partially at the moment) diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index c92fc84a3c1..562c20f728f 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -78,7 +78,7 @@ php ${install_cmd} # php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} # Configure Varnish FPC, if enabled -sh ${vagrant_dir}/scripts/guest/m-reinstall-scripts/config_varnish +sh ${vagrant_dir}/scripts/guest/m-reinstall-scripts/configure_varnish # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - diff --git a/scripts/guest/m-reinstall-scripts/config_varnish b/scripts/guest/m-reinstall-scripts/configure_varnish similarity index 52% rename from scripts/guest/m-reinstall-scripts/config_varnish rename to scripts/guest/m-reinstall-scripts/configure_varnish index 4c34ef9b8de..104a039f2b1 100644 --- a/scripts/guest/m-reinstall-scripts/config_varnish +++ b/scripts/guest/m-reinstall-scripts/configure_varnish @@ -12,16 +12,16 @@ use_varnish=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_use if [ $use_varnish -eq 1 ]; then # Configure apache files to be ready for varnish - if [ -z "$(grep "VirtualHost\s\*:8080" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf)" ]; then - sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf + if [ -z "$(grep "VirtualHost\s\*:8080" /etc/apache2/sites-enabled/magento2.conf)" ]; then + sudo sed -ie "s//" /etc/apache2/sites-enabled/magento2.conf restart_services=1 fi - if [ -z "$(grep "VirtualHost\s\*:8080" /vagrant/etc/guest/apache2/sites-available/magento2.conf)" ]; then - sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-available/magento2.conf + if [ -z "$(grep "VirtualHost\s\*:8080" /etc/apache2/sites-available/magento2.conf)" ]; then + sudo sed -ie "s//" /etc/apache2/sites-available/magento2.conf restart_services=1 fi - if [ -z "$(grep "Listen\s8080" /vagrant/etc/guest/apache2/ports.conf)" ]; then - sudo sed -ie "s/Listen 80/Listen 8080/" /vagrant/etc/guest/apache2/ports.conf + if [ -z "$(grep "Listen\s8080" /etc/apache2/ports.conf)" ]; then + sudo sed -ie "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf restart_services=1 fi @@ -33,16 +33,16 @@ if [ $use_varnish -eq 1 ]; then else # Configure apache files to run without varnish - if [ -z "$(grep "VirtualHost\s\*:80\b" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf)" ]; then - sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-enabled/magento2.conf + if [ -z "$(grep "VirtualHost\s\*:80\b" /etc/apache2/sites-enabled/magento2.conf)" ]; then + sudo sed -ie "s//" /etc/apache2/sites-enabled/magento2.conf restart_services=1 fi - if [ -z "$(grep "VirtualHost\s\*:80\b" /vagrant/etc/guest/apache2/sites-available/magento2.conf)" ]; then - sudo sed -ie "s//" /vagrant/etc/guest/apache2/sites-available/magento2.conf + if [ -z "$(grep "VirtualHost\s\*:80\b" /etc/apache2/sites-available/magento2.conf)" ]; then + sudo sed -ie "s//" /etc/apache2/sites-available/magento2.conf restart_services=1 fi - if [ -z "$(grep "Listen\s80\b" /vagrant/etc/guest/apache2/ports.conf)" ]; then - sudo sed -ie "s/Listen 8080/Listen 80/" /vagrant/etc/guest/apache2/ports.conf + if [ -z "$(grep "Listen\s80\b" /etc/apache2/ports.conf)" ]; then + sudo sed -ie "s/Listen 8080/Listen 80/" /etc/apache2/ports.conf restart_services=1 fi fi @@ -57,6 +57,6 @@ if [ $restart_services -eq 1 ]; then fi sudo apache2ctl start if [ $use_varnish -eq 1 ]; then - sudo varnishd -f /vagrant/etc/guest/varnish/default.vcl + sudo varnishd -f /etc/varnish/default.vcl fi fi From 4d8b18af24bf43920f4bc386d04ca82eb5c2a311 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 9 May 2016 15:26:31 -0500 Subject: [PATCH 029/173] - Guest configs editable from IDE (https://github.com/paliarush/magento2-vagrant-for-developers/issues/29) - Added ability to choose if PhpStorm configs should be removed during project reinitialization --- CHANGELOG.md | 17 +++++++++-------- README.md | 10 +++++++++- init_project.sh | 12 ++++++++---- scripts/guest/link_configs | 16 ++++++++++------ scripts/guest/unlink_configs | 7 +------ 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae87dd1caf2..f3006ec9f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added host wrapper script for bin/magento command on guest - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE + - Added ability to choose if PhpStorm configs should be removed during project reinitialization ## [v2.0.0] - 2016-02-05 @@ -52,18 +53,18 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - - Integrated vagrant host manager plugin to allow automatic /etc/hosts update - - Added support of EE linked to CE using symlinks on *nix hosts + - Integrated vagrant host manager plugin to allow automatic /etc/hosts update + - Added support of EE linked to CE using symlinks on *nix hosts - Added ${MAGENTO_ROOT} environment variable, which stores installation path on the guest - Added support of Rabbit MQ - - Added possibility to specify tokens for repo.magento.com composer repository + - Added possibility to specify tokens for repo.magento.com composer repository - git is now installed on guest machine - - Removed 'magento' MySQL user, password of 'root' user removed - - Database for integration tests are created by default - - Added script for clearing Magento cache from host command line + - Removed 'magento' MySQL user, password of 'root' user removed + - Database for integration tests are created by default + - Added script for clearing Magento cache from host command line - Configured XDebug to allow remote debugging - - Fixed max_nesting_level issue with XDebug enabled + - Fixed max_nesting_level issue with XDebug enabled - Apache is run by 'vagrant' user - - Enabled Magento cron jobs + - Enabled Magento cron jobs - Enabled XDebug by default - Created vagrant configuration for Magneto 2 CE developer's environment installation diff --git a/README.md b/README.md index a7b264f452c..25a95058233 100755 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-dev ### Accessing PHP and other config files -It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes, but not limited to: PHP, Apache, Mysql, Varnish, RabbitMQ, hosts, cron. +It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes: PHP, Apache, Mysql, Varnish, RabbitMQ. Do not edit any symlinks using PhpStorm because it may break your installation. After editing configs in IDE it is still required to restart related services manually. @@ -240,3 +240,11 @@ Go to 'vagrant-magento' created earlier and run in command line: ``` bash init_project.sh -fc ``` + +To reset PhpStorm project configuration, in addition to `-f` specify `-p` option: + +``` +bash init_project.sh -fp +OR +bash init_project.sh -fcp +``` \ No newline at end of file diff --git a/init_project.sh b/init_project.sh index 4668a1a50ab..09f7e50c4a6 100755 --- a/init_project.sh +++ b/init_project.sh @@ -37,10 +37,12 @@ rm -f "${config_path}.back" # Clean up the project before initialization if "-f" option was specified. Remove codebase if "-fc" is used. force_project_cleaning=0 force_codebase_cleaning=0 -while getopts 'fc' flag; do +force_phpstorm_config_cleaning=0 +while getopts 'fcp' flag; do case "${flag}" in f) force_project_cleaning=1 ;; c) force_codebase_cleaning=1 ;; + p) force_phpstorm_config_cleaning=1 ;; *) error "Unexpected option ${flag}" ;; esac done @@ -82,10 +84,12 @@ vagrant up set +x echo "Configuring PhpStorm..." -if [ ${force_project_cleaning} -eq 1 ]; then - rm -rf ${vagrant_dir}/.idea/* +if [ ${force_project_cleaning} -eq 1 ] && [ ${force_phpstorm_config_cleaning} -eq 1 ]; then + rm -rf ${vagrant_dir}/.idea +fi +if [ ! "$(ls -A ${vagrant_dir}/.idea)" ]; then + bash "${vagrant_dir}/scripts/host/configure_php_storm.sh" fi -bash "${vagrant_dir}/scripts/host/configure_php_storm.sh" bold=$(tput bold) regular=$(tput sgr0) diff --git a/scripts/guest/link_configs b/scripts/guest/link_configs index de6d2c34916..1ce59629b23 100755 --- a/scripts/guest/link_configs +++ b/scripts/guest/link_configs @@ -19,15 +19,19 @@ function process_configs () { # Enable trace printing and exit on the first error set -ex +# Below configuration is required to allow managing mysql as a service +if ! cat /etc/apparmor.d/local/usr.sbin.mysqld | grep -q '/vagrant/etc/guest' ; then + echo " + /vagrant/etc/guest/mysql/*.pem r, + /vagrant/etc/guest/mysql/conf.d/ r, + /vagrant/etc/guest/mysql/conf.d/* r, + /vagrant/etc/guest/mysql/*.cnf r," >> /etc/apparmor.d/local/usr.sbin.mysqld +fi + # Make guest configs visible and editable in the host IDE # Configs located under /etc/* config_dir="/etc" # See unlink_configs script -configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d ) +configs=( apache2 php mysql varnish rabbitmq ) process_configs ${config_dir} ${configs} - -# Configs located under ~/* -config_dir="/home/vagrant" -configs=( .bashrc .composer .profile ) -process_configs ${config_dir} ${configs} \ No newline at end of file diff --git a/scripts/guest/unlink_configs b/scripts/guest/unlink_configs index bf706f0e85e..d4ae3478757 100755 --- a/scripts/guest/unlink_configs +++ b/scripts/guest/unlink_configs @@ -23,10 +23,5 @@ set -ex # Configs located under /etc/* config_dir="/etc" # See link_configs script -configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d ) -process_configs ${config_dir} ${configs} - -# Configs located under ~/* -config_dir="/home/vagrant" -configs=( .bashrc .composer .profile ) +configs=( apache2 php mysql varnish rabbitmq ) process_configs ${config_dir} ${configs} From 5b370228c7f69805edc719ca261fe83fb747f250 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 11 May 2016 10:10:31 -0500 Subject: [PATCH 030/173] Fixed "stdin: is not a tty" warning --- CHANGELOG.md | 1 + Vagrantfile | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3006ec9f07..528aeb10414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fixed permissions during Magento installation on Windows hosts - Fixed issue with Magento compiler on Windows hosts + - Fixed "stdin: is not a tty" warning ### Added diff --git a/Vagrantfile b/Vagrantfile index bad62452dff..6ec852a49fe 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -69,6 +69,11 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| host_vagrant_dir #7 ] + config.vm.provision "fix_no_tty", type: "shell", run: "always" do |s| + s.privileged = false + s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile" + end + config.vm.provision "configure_environment", type: "shell" do |s| s.path = "scripts/provision/configure_environment.sh" s.args = shell_script_args From bfd05a3f0c3cf5d16b2e26ac53a21dc9280db840 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Thu, 12 May 2016 16:30:43 +0300 Subject: [PATCH 031/173] fixed an issue with access to mysql --- scripts/guest/m-reinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 73713e402df..ec9805567e6 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -39,7 +39,7 @@ rm -f "${MAGENTO_ROOT}/app/etc/env.php" # Create DB db_names=(${setupOptions[db_name]} "magento_integration_tests" ) for db_name in "${db_names[@]}"; do - mysql -e "drop database if exists ${db_name}; create database ${db_name};" + mysql -uroot -e "drop database if exists ${db_name}; create database ${db_name};" done # Install Magento application From dd43468be546b44dd9edc9a484ebc72f64ee571b Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Fri, 13 May 2016 19:43:51 +0300 Subject: [PATCH 032/173] - removed previous fix - added mount options --- Vagrantfile | 2 +- scripts/guest/m-reinstall | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 6ec852a49fe..dc7a3a469c8 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -47,7 +47,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| end config.vm.synced_folder '.', '/vagrant', disabled: true - config.vm.synced_folder './etc', '/vagrant/etc' + config.vm.synced_folder './etc', '/vagrant/etc', mount_options: ["dmode=775,fmode=664"] config.vm.synced_folder './scripts', '/vagrant/scripts' config.vm.synced_folder './.idea', '/vagrant/.idea', create: true if use_nfs_for_synced_folders diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index ec9805567e6..73713e402df 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -39,7 +39,7 @@ rm -f "${MAGENTO_ROOT}/app/etc/env.php" # Create DB db_names=(${setupOptions[db_name]} "magento_integration_tests" ) for db_name in "${db_names[@]}"; do - mysql -uroot -e "drop database if exists ${db_name}; create database ${db_name};" + mysql -e "drop database if exists ${db_name}; create database ${db_name};" done # Install Magento application From 0903d5ca5f3a3454a441698faca1c77f25cb1f10 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Fri, 20 May 2016 19:35:26 +0300 Subject: [PATCH 033/173] - co-install php5.6 and 7 - scope for changing version of php is "vagrant reload" --- etc/config.yaml.dist | 2 +- scripts/provision/configure_environment.sh | 44 +++++++++---------- .../configure_environment_recurring.sh | 15 ++++++- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index 92dcd23c89c..68a3e5fd5c7 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -9,7 +9,7 @@ guest: ip_address: "192.168.10.2" forwarded_ssh_port: 3000 environment: - # If set to 0, PHP 5 will be installed + # If set to 0, PHP 5 will be installed. [Changeable: vagrant reload] use_php7: 1 composer_prefer_source: 0 magento: diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index 5f4c0a2567d..ef98d6a236c 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -30,31 +30,29 @@ a2ensite magento2.conf sudo a2dissite 000-default # Setup PHP -if [ ${use_php7} -eq 1 ]; then - sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" /etc/php/7.0/cli/php.ini - sed -i "s|display_errors = Off|display_errors = On|g" /etc/php/7.0/cli/php.ini - sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" /etc/php/7.0/cli/php.ini - sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" /etc/php/7.0/cli/php.ini -else - # Uninstall PHP 7 pre-installed in the box - apt-get remove -y php* +sudo add-apt-repository ppa:ondrej/php +sudo apt-get update +apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 +echo ' +xdebug.max_nesting_level=200 +xdebug.remote_enable=1 +xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini - # Install PHP 5 - apt-get install -y php5 php5-mhash php5-mcrypt php5-curl php5-cli php5-mysql php5-gd php5-intl php5-xsl php5-xdebug curl - if [ ! -f /etc/php5/apache2/conf.d/20-mcrypt.ini ]; then - ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini - fi - if [ ! -f /etc/php5/cli/conf.d/20-mcrypt.ini ]; then - ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/cli/conf.d/20-mcrypt.ini - fi - echo "date.timezone = America/Chicago" >> /etc/php5/cli/php.ini +php_ini_path=/etc/php/7.0/cli/php.ini +echo "date.timezone = America/Chicago" >> ${php_ini_path} +sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} +sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} +sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} +sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} + +php_ini_path=/etc/php/5.6/cli/php.ini +echo "date.timezone = America/Chicago" >> ${php_ini_path} +sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} +sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} +sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} +sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} +#end Setup PHP - # Configure XDebug to allow remote connections from the host - echo 'xdebug.max_nesting_level=200 - xdebug.remote_enable=1 - xdebug.remote_connect_back=1' >> /etc/php5/cli/conf.d/20-xdebug.ini -fi -service apache2 restart # Configure composer composer_auth_json="${vagrant_dir}/etc/composer/auth.json" diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 1031d9b41b9..2bee8161873 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -3,6 +3,8 @@ # Enable trace printing and exit on the first error set +x +use_php7=$4 + vagrant_dir="/vagrant" # Remove configs from host in case of force stop of virtual machine before linking restored ones @@ -25,4 +27,15 @@ fi # Upgrade existing environment if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "${vagrant_dir}/.idea/deployment.xml" -fi \ No newline at end of file +fi + +# Setup PHP +if [ ${use_php7} -eq 1 ]; then + update-alternatives --set php /usr/bin/php7.0 && a2dismod php5.6 && a2enmod php7.0 +else + update-alternatives --set php /usr/bin/php5.6 && a2dismod php7.0 && a2enmod php5.6 + rm -f /etc/php/5.6/apache2/php.ini + ln -s /etc/php/5.6/cli/php.ini /etc/php/5.6/apache2/php.ini +fi +service apache2 restart +#end Setup PHP From 2f5ee4d82d64d21a2ba49c9331f7431663510c00 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Fri, 20 May 2016 19:41:25 +0300 Subject: [PATCH 034/173] -updated doc for php versions --- README.md | 10 +++------- etc/config.yaml.dist | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 25a95058233..938595fcad6 100755 --- a/README.md +++ b/README.md @@ -167,15 +167,11 @@ bash m-switch-to-ee ``` :information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key. +### Switch between PHP 5.6 and 7 +Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist) ### Update Composer dependencies -Go to 'vagrant-magento' created earlier and run in command line: - -``` -bash m-composer install -OR -bash m-composer update -``` +PHP version will be applied after "vagrant reload" ### Use Magento CLI (bin/magento) diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index 68a3e5fd5c7..84c916e9b53 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -9,7 +9,7 @@ guest: ip_address: "192.168.10.2" forwarded_ssh_port: 3000 environment: - # If set to 0, PHP 5 will be installed. [Changeable: vagrant reload] + # If set to 0, PHP 5 will be installed. [Changeable: vagrant reload] use_php7: 1 composer_prefer_source: 0 magento: From db33153c92e228f36319d65c5b70d2efad735286 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Fri, 20 May 2016 21:13:16 +0300 Subject: [PATCH 035/173] -updated doc for php versions --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 938595fcad6..aae34f90fbc 100755 --- a/README.md +++ b/README.md @@ -168,10 +168,19 @@ bash m-switch-to-ee :information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key. ### Switch between PHP 5.6 and 7 -Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist) + +Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist). +PHP version will be applied after "vagrant reload". + ### Update Composer dependencies -PHP version will be applied after "vagrant reload" +Go to 'vagrant-magento' created earlier and run in command line: + +``` +bash m-composer install +OR +bash m-composer update +``` ### Use Magento CLI (bin/magento) From e7e5c9a12c64b33248ed2efc628a4d23e0e56530 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Mon, 23 May 2016 18:47:19 +0300 Subject: [PATCH 036/173] -updated changelog - change for switching PHP versions has been made backward compatible --- CHANGELOG.md | 2 ++ scripts/provision/configure_environment.sh | 25 ------------------- .../configure_environment_recurring.sh | 23 +++++++++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 528aeb10414..72898db2687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) - Changed requirement for minimum box version from 1.0 to 1.1 + - Upgraded PHP 5.5.9 to PHP 5.6 + - Updated switching PHP versions. Now it is applicable after "vagrant reload" ### Fixed diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index ef98d6a236c..ec0b47f69c4 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -29,31 +29,6 @@ a2ensite magento2.conf # Disable default virtual host sudo a2dissite 000-default -# Setup PHP -sudo add-apt-repository ppa:ondrej/php -sudo apt-get update -apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 -echo ' -xdebug.max_nesting_level=200 -xdebug.remote_enable=1 -xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini - -php_ini_path=/etc/php/7.0/cli/php.ini -echo "date.timezone = America/Chicago" >> ${php_ini_path} -sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} -sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} -sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} -sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} - -php_ini_path=/etc/php/5.6/cli/php.ini -echo "date.timezone = America/Chicago" >> ${php_ini_path} -sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} -sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} -sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} -sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} -#end Setup PHP - - # Configure composer composer_auth_json="${vagrant_dir}/etc/composer/auth.json" if [ -f ${composer_auth_json} ]; then diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 2bee8161873..b0f4e43125b 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -1,5 +1,17 @@ #!/usr/bin/env bash +function process_php_config () { + php_ini_paths=$1 + for php_ini_path in "${php_ini_paths[@]}" + do + echo "date.timezone = America/Chicago" >> ${php_ini_path} + sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} + sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} + sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} + sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} + done +} + # Enable trace printing and exit on the first error set +x @@ -30,6 +42,17 @@ if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then fi # Setup PHP +sudo add-apt-repository ppa:ondrej/php +sudo apt-get update +apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 +echo ' +xdebug.max_nesting_level=200 +xdebug.remote_enable=1 +xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini + +php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) +process_php_config ${php_ini_paths} + if [ ${use_php7} -eq 1 ]; then update-alternatives --set php /usr/bin/php7.0 && a2dismod php5.6 && a2enmod php7.0 else From da40348f93a1ac1f55cca21d3ceeb9fc144af9f2 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Thu, 26 May 2016 12:28:09 -0500 Subject: [PATCH 037/173] - Fixed gitignore removal from unit tests tmp during cache clearing - Added support for CYGWIN on Windows - Fixed removal of auth.json which was committed to the root of Magento project --- scripts/guest/m-clear-cache | 2 +- scripts/host/composer.sh | 13 +++++++++---- scripts/host/get_host_os.sh | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/guest/m-clear-cache b/scripts/guest/m-clear-cache index bfc896e58f5..3d67ee761ca 100755 --- a/scripts/guest/m-clear-cache +++ b/scripts/guest/m-clear-cache @@ -10,6 +10,6 @@ cd ${MAGENTO_ROOT}/pub && mv static/.htaccess static_htaccess.back && rm -rf sta #clear integration tests tmp cd ${MAGENTO_ROOT}/dev/tests/integration && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore #clear unit tests tmp -cd ${MAGENTO_ROOT}/dev/tests/unit && rm -rf tmp && mkdir tmp +cd ${MAGENTO_ROOT}/dev/tests/unit && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore echo "Magento cache cleared." diff --git a/scripts/host/composer.sh b/scripts/host/composer.sh index 7897c75f22d..f431d7080ef 100755 --- a/scripts/host/composer.sh +++ b/scripts/host/composer.sh @@ -22,9 +22,14 @@ if [ ! -f ${composer_phar} ]; then fi # Configure composer credentials +auth_json_already_exists=0 +if [ -f "${current_dir}/auth.json" ]; then + auth_json_already_exists=1 +fi + cd ${current_dir} -if [ -f ${composer_auth_json} ]; then - cp ${composer_auth_json} "${PWD}/auth.json" +if [ ! ${auth_json_already_exists} = 1 ] && [ -f ${composer_auth_json} ]; then + cp ${composer_auth_json} "${current_dir}/auth.json" fi host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") @@ -35,6 +40,6 @@ else ${php_executable} ${composer_phar} --ignore-platform-reqs "$@" fi -if [ -f "${PWD}/auth.json" ]; then - rm "${PWD}/auth.json" +if [ ! ${auth_json_already_exists} = 1 ] && [ -f "${current_dir}/auth.json" ]; then + rm "${current_dir}/auth.json" fi diff --git a/scripts/host/get_host_os.sh b/scripts/host/get_host_os.sh index 9a806bc0a79..b4ebee75303 100644 --- a/scripts/host/get_host_os.sh +++ b/scripts/host/get_host_os.sh @@ -6,6 +6,8 @@ elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then echo "Linux" elif [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then echo "Windows" +elif [ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]; then + echo "Windows" else echo "Unknown host OS" exit 255 From cb4890073fb3e1863b18732416961c2fcfa382dd Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Tue, 31 May 2016 21:33:41 +0300 Subject: [PATCH 038/173] -updated recurring script --- .../provision/configure_environment_recurring.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index b0f4e43125b..9b01209d459 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -42,13 +42,15 @@ if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then fi # Setup PHP -sudo add-apt-repository ppa:ondrej/php -sudo apt-get update -apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 -echo ' -xdebug.max_nesting_level=200 -xdebug.remote_enable=1 -xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini +if [ ! -d "/etc/php/5.6" ]; then + sudo add-apt-repository ppa:ondrej/php + sudo apt-get update + sudo apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 + echo ' + xdebug.max_nesting_level=200 + xdebug.remote_enable=1 + xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini +fi php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) process_php_config ${php_ini_paths} From 4c08aa2b1931871617287040185d741ad48b2e4a Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Tue, 31 May 2016 21:52:15 +0300 Subject: [PATCH 039/173] -updated recurring script --- .../configure_environment_recurring.sh | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 9b01209d459..6f81c014469 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -12,6 +12,16 @@ function process_php_config () { done } +function init_php56 () { + sudo add-apt-repository ppa:ondrej/php + sudo apt-get update + sudo apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 + echo ' + xdebug.max_nesting_level=200 + xdebug.remote_enable=1 + xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini +} + # Enable trace printing and exit on the first error set +x @@ -42,22 +52,15 @@ if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then fi # Setup PHP -if [ ! -d "/etc/php/5.6" ]; then - sudo add-apt-repository ppa:ondrej/php - sudo apt-get update - sudo apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 - echo ' - xdebug.max_nesting_level=200 - xdebug.remote_enable=1 - xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini -fi - php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) process_php_config ${php_ini_paths} if [ ${use_php7} -eq 1 ]; then update-alternatives --set php /usr/bin/php7.0 && a2dismod php5.6 && a2enmod php7.0 else + if [ ! -d "/etc/php/5.6" ]; then + init_php56 + fi update-alternatives --set php /usr/bin/php5.6 && a2dismod php7.0 && a2enmod php5.6 rm -f /etc/php/5.6/apache2/php.ini ln -s /etc/php/5.6/cli/php.ini /etc/php/5.6/apache2/php.ini From f2da2bc53c967e3dd6cfc5b878376159581c3adb Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Tue, 31 May 2016 22:28:52 +0300 Subject: [PATCH 040/173] -updated recurring script --- .../configure_environment_recurring.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 6f81c014469..4890c15180c 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -2,13 +2,16 @@ function process_php_config () { php_ini_paths=$1 + for php_ini_path in "${php_ini_paths[@]}" do - echo "date.timezone = America/Chicago" >> ${php_ini_path} - sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} - sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} - sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} - sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} + if [ -f ${php_ini_path} ]; then + echo "date.timezone = America/Chicago" >> ${php_ini_path} + sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} + sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} + sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} + sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} + fi done } @@ -56,7 +59,11 @@ php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) process_php_config ${php_ini_paths} if [ ${use_php7} -eq 1 ]; then - update-alternatives --set php /usr/bin/php7.0 && a2dismod php5.6 && a2enmod php7.0 + update-alternatives --set php /usr/bin/php7.0 + if [ -d "/etc/php/5.6" ]; then + a2dismod php5.6 + fi + a2enmod php7.0 else if [ ! -d "/etc/php/5.6" ]; then init_php56 From 4e5628ccdbc78ca688627776852e89f97385b3c7 Mon Sep 17 00:00:00 2001 From: Arkadii Chyzhov Date: Wed, 1 Jun 2016 18:17:00 +0300 Subject: [PATCH 041/173] -updated changelog.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72898db2687..92d20d7d08f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) - Changed requirement for minimum box version from 1.0 to 1.1 - Upgraded PHP 5.5.9 to PHP 5.6 - - Updated switching PHP versions. Now it is applicable after "vagrant reload" ### Fixed @@ -27,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added host wrapper script for bin/magento command on guest - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE - Added ability to choose if PhpStorm configs should be removed during project reinitialization + - Added ability to switch PHP version without destroying the project ("vagrant reload" is required) ## [v2.0.0] - 2016-02-05 From 7800d20dd835319e1159dd72fd6f75a2c263934d Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 1 Jun 2016 12:48:03 -0500 Subject: [PATCH 042/173] Update README.md --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index aae34f90fbc..341e2d67a72 100755 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ * [Debugging with XDebug](#debugging-with-xdebug) * [Connecting to MySQL DB](#connecting-to-mysql-db) * [Accessing PHP and other config files](#accessing-php-and-other-config-files) + * [Switch between PHP 5.6 and 7.0](#switch-between-php-56-and-70) * [Multiple Magento instances](#multiple-magento-instances) * [Reset environment](#reset-environment) @@ -167,11 +168,6 @@ bash m-switch-to-ee ``` :information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key. -### Switch between PHP 5.6 and 7 - -Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist). -PHP version will be applied after "vagrant reload". - ### Update Composer dependencies Go to 'vagrant-magento' created earlier and run in command line: @@ -223,6 +219,11 @@ Do not edit any symlinks using PhpStorm because it may break your installation. After editing configs in IDE it is still required to restart related services manually. +### Switch between PHP 5.6 and 7.0 + +Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist). +PHP version will be applied after "vagrant reload". + ### Multiple Magento instances To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host. @@ -252,4 +253,4 @@ To reset PhpStorm project configuration, in addition to `-f` specify `-p` option bash init_project.sh -fp OR bash init_project.sh -fcp -``` \ No newline at end of file +``` From 26f0f66a79bfc581446235534bb5f8f8f7ebcd7f Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Wed, 1 Jun 2016 17:59:38 -0500 Subject: [PATCH 043/173] Updated README - To include information about Varnish. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 41626d130ae..94233fd5249 100755 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ * [Connecting to MySQL DB](#connecting-to-mysql-db) * [Accessing PHP and other config files](#accessing-php-and-other-config-files) * [Switch between PHP 5.6 and 7.0](#switch-between-php-56-and-70) + * [Activating Varnish](#activating-varnish) * [Multiple Magento instances](#multiple-magento-instances) * [Reset environment](#reset-environment) @@ -224,6 +225,13 @@ After editing configs in IDE it is still required to restart related services ma Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist). PHP version will be applied after "vagrant reload". +### Activating Varnish + +Set "use_varnish: 1" to use varnish along apache in [config.yaml](etc/config.yaml.dist). +Running m-reinstall script will apply your preference. +It will use default file etc/magento2_default_varnish.vcl.dist generated from a Magento instance. +Varnish Version: 3.0.5 + ### Multiple Magento instances To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host. From daaa3b26f2f2dcd341a3d333204ff1965c1bd86b Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 1 Jun 2016 23:23:03 -0500 Subject: [PATCH 044/173] Added email logging support (#9) --- CHANGELOG.md | 1 + README.md | 6 ++++ Vagrantfile | 1 + init_project.sh | 1 + log/email/.gitignore | 1 + scripts/guest/log_email | 31 +++++++++++++++++++ .../configure_environment_recurring.sh | 14 ++++++++- 7 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 log/email/.gitignore create mode 100755 scripts/guest/log_email diff --git a/CHANGELOG.md b/CHANGELOG.md index 92d20d7d08f..764a4a754bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added + - Added logging of all emails in HTML format to `vagrant-magento/log/email` - Added host wrapper script for bin/magento command on guest - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE - Added ability to choose if PhpStorm configs should be removed during project reinitialization diff --git a/README.md b/README.md index 341e2d67a72..039d994478f 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ * [Use Magento CLI (bin/magento)](#use-magento-cli-binmagento) * [Debugging with XDebug](#debugging-with-xdebug) * [Connecting to MySQL DB](#connecting-to-mysql-db) + * [View emails sent by Magento](#view-emails-sent-by-magento) * [Accessing PHP and other config files](#accessing-php-and-other-config-files) * [Switch between PHP 5.6 and 7.0](#switch-between-php-56-and-70) * [Multiple Magento instances](#multiple-magento-instances) @@ -134,6 +135,7 @@ Note, that semantic versioning is only used for `x.0` branches (not for `develop 1. Make sure that you used `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`) 1. If code is not synchronized properly on Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly), make sure that PhpStorm is running before making any changes in the code. This is important because otherwise PhpStorm will not be able to detect changes and upload them to the guest machine 1. Please make sure that currently installed software, specified in [requirements section](#requirements), meets minimum version requirement + 1. If MySQL fails to start and Magento reinstallation fails with `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)`, try to run login to virtual machine using `vagrant ssh` and then run `sudo dpkg-reconfigure mysql-server-5.6`, then `sudo service mysql restart.` ## Day-to-day development scenarios @@ -212,6 +214,10 @@ To debug Magento Setup script, go to [Magento installation script](scripts/guest Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-developers/issues/8) +### View emails sent by Magento + +All emails are saved to 'vagrant-magento/log/email' in HTML format. + ### Accessing PHP and other config files It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes: PHP, Apache, Mysql, Varnish, RabbitMQ. diff --git a/Vagrantfile b/Vagrantfile index dc7a3a469c8..4fe51ba16ee 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -49,6 +49,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.synced_folder '.', '/vagrant', disabled: true config.vm.synced_folder './etc', '/vagrant/etc', mount_options: ["dmode=775,fmode=664"] config.vm.synced_folder './scripts', '/vagrant/scripts' + config.vm.synced_folder './log', '/vagrant/log' config.vm.synced_folder './.idea', '/vagrant/.idea', create: true if use_nfs_for_synced_folders guest_magento_dir = host_magento_dir diff --git a/init_project.sh b/init_project.sh index 09f7e50c4a6..488dda9d51b 100755 --- a/init_project.sh +++ b/init_project.sh @@ -52,6 +52,7 @@ if [ ${force_project_cleaning} -eq 1 ]; then rm -rf ${vagrant_dir}/.vagrant ${vagrant_dir}/etc/guest mkdir ${vagrant_dir}/etc/guest mv ${vagrant_dir}/etc/.gitignore.back ${vagrant_dir}/etc/guest/.gitignore + cd ${vagrant_dir}/log && mv email/.gitignore email_gitignore.back && rm -rf email && mkdir email && mv email_gitignore.back email/.gitignore if [ ${force_codebase_cleaning} -eq 1 ]; then rm -rf ${magento_ce_dir} fi diff --git a/log/email/.gitignore b/log/email/.gitignore new file mode 100644 index 00000000000..f59ec20aabf --- /dev/null +++ b/log/email/.gitignore @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/scripts/guest/log_email b/scripts/guest/log_email new file mode 100755 index 00000000000..53c1a9b95d5 --- /dev/null +++ b/scripts/guest/log_email @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +email_log_dir=$1 +if [ ! -d ${email_log_dir} ]; then + mkdir -p ${email_log_dir} +fi + +# Construct email file path +current_time=$( date +"%Y-%m-%d_%H-%M-%S" ) +# Add random suffix to file name just in case there several emails sent in one second +random_suffix=$(( RANDOM % 100 )) +email_file_path="${email_log_dir}/${current_time}_${random_suffix}" + +raw_email_output=$(cat) + +# Add email topic to file name +pattern="Subject: (.*)\sX-PHP-Originating-Script:" +if [[ "${raw_email_output}" =~ ${pattern} ]]; then + email_topic=${BASH_REMATCH[1]} + email_file_path="${email_file_path}_${email_topic}" +fi +email_file_path="${email_file_path}.html" + +# Output content +echo ${raw_email_output} > "${email_file_path}" + +# Process raw content of an email to make it a valid HTML +sed -i "s|.*<\!DOCTYPE|<\!DOCTYPE|g" "${email_file_path}" +sed -i "s|=3D|=|g" "${email_file_path}" +sed -i "s|=0A||g" "${email_file_path}" +sed -i "s|= ||g" "${email_file_path}" \ No newline at end of file diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 4890c15180c..1acd97e7bd7 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -29,7 +29,6 @@ function init_php56 () { set +x use_php7=$4 - vagrant_dir="/vagrant" # Remove configs from host in case of force stop of virtual machine before linking restored ones @@ -74,3 +73,16 @@ else fi service apache2 restart #end Setup PHP + +# Enable email logging +if [ ${use_php7} -eq 1 ]; then + php_ini_file="/etc/php/7.0/cli/php.ini" +else + php_ini_file="/etc/php/5.6/cli/php.ini" +fi +pattern=";sendmail_path" +php_config_content="$(cat ${php_ini_file})" +if [[ ${php_config_content} =~ ${pattern} ]]; then + sed -i "s|;sendmail_path =|sendmail_path = \"/vagrant/scripts/guest/log_email ${vagrant_dir}/log/email\"|g" ${php_ini_file} + service apache2 restart +fi From d4c6f3b1e20f0a7432a630c3ee1a9570fec5c9d0 Mon Sep 17 00:00:00 2001 From: Rico Neitzel Date: Wed, 8 Jun 2016 13:30:53 +0200 Subject: [PATCH 045/173] fixed path shell args --- init_project.sh | 22 +++++++++---------- scripts/get_config_value.sh | 2 +- scripts/host/composer.sh | 10 ++++----- scripts/host/configure_php_storm.sh | 6 ++--- scripts/host/install_php.sh | 8 +++---- scripts/provision/configure_environment.sh | 8 +++---- .../configure_environment_recurring.sh | 6 ++--- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/init_project.sh b/init_project.sh index 09f7e50c4a6..f6efba2ebdd 100755 --- a/init_project.sh +++ b/init_project.sh @@ -25,7 +25,7 @@ fi # Generate random IP address and host name to prevent collisions, if not specified explicitly in local config if [ ! -f "${vagrant_dir}/etc/config.yaml" ]; then - cp "${config_path}.dist" ${config_path} + cp "${config_path}.dist" "${config_path}" fi random_ip=$(( ( RANDOM % 240 ) + 12 )) forwarded_ssh_port=$(( random_ip + 3000 )) @@ -48,12 +48,12 @@ while getopts 'fcp' flag; do done if [ ${force_project_cleaning} -eq 1 ]; then vagrant destroy -f - mv ${vagrant_dir}/etc/guest/.gitignore ${vagrant_dir}/etc/.gitignore.back - rm -rf ${vagrant_dir}/.vagrant ${vagrant_dir}/etc/guest - mkdir ${vagrant_dir}/etc/guest - mv ${vagrant_dir}/etc/.gitignore.back ${vagrant_dir}/etc/guest/.gitignore if [ ${force_codebase_cleaning} -eq 1 ]; then - rm -rf ${magento_ce_dir} + mv "${vagrant_dir}/etc/guest/.gitignore" "${vagrant_dir}/etc/.gitignore.back" + rm -rf "${vagrant_dir}/.vagrant" "${vagrant_dir}/etc/guest" + mkdir "${vagrant_dir}/etc/guest" + mv "${vagrant_dir}/etc/.gitignore.back" "${vagrant_dir}/etc/guest/.gitignore" + rm -rf "${magento_ce_dir}" fi fi @@ -65,27 +65,27 @@ if [ ! -d ${magento_ce_dir} ]; then fi # Check out CE repository repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce") - git clone ${repository_url_ce} ${magento_ce_dir} + git clone ${repository_url_ce} "${magento_ce_dir}" # Check out EE repository # By default EE repository is not specified and EE project is not checked out repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee") if [ -n "${repository_url_ee}" ]; then - git clone ${repository_url_ee} ${magento_ee_dir} + git clone ${repository_url_ee} "${magento_ee_dir}" fi fi # Update Magento dependencies via Composer -cd ${magento_ce_dir} +cd "${magento_ce_dir}" bash "${vagrant_dir}/scripts/host/composer.sh" install # Create vagrant project -cd ${vagrant_dir} +cd "${vagrant_dir}" vagrant up set +x echo "Configuring PhpStorm..." if [ ${force_project_cleaning} -eq 1 ] && [ ${force_phpstorm_config_cleaning} -eq 1 ]; then - rm -rf ${vagrant_dir}/.idea + rm -rf "${vagrant_dir}/.idea" fi if [ ! "$(ls -A ${vagrant_dir}/.idea)" ]; then bash "${vagrant_dir}/scripts/host/configure_php_storm.sh" diff --git a/scripts/get_config_value.sh b/scripts/get_config_value.sh index 2c59746db46..7e19a9cf17a 100644 --- a/scripts/get_config_value.sh +++ b/scripts/get_config_value.sh @@ -5,7 +5,7 @@ parse_yaml() { local prefix=$2 local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ - -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | awk -F$fs '{ indent = length($1)/2; vname[indent] = $2; diff --git a/scripts/host/composer.sh b/scripts/host/composer.sh index f431d7080ef..c4631de1aff 100755 --- a/scripts/host/composer.sh +++ b/scripts/host/composer.sh @@ -17,7 +17,7 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Setup composer if necessary if [ ! -f ${composer_phar} ]; then - cd ${composer_dir} + cd "${composer_dir}" curl -sS https://getcomposer.org/installer | ${php_executable} fi @@ -27,17 +27,17 @@ if [ -f "${current_dir}/auth.json" ]; then auth_json_already_exists=1 fi -cd ${current_dir} if [ ! ${auth_json_already_exists} = 1 ] && [ -f ${composer_auth_json} ]; then - cp ${composer_auth_json} "${current_dir}/auth.json" +cd "${current_dir}" + cp "${composer_auth_json}" "${current_dir}/auth.json" fi host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") if [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_composer_prefer_source") == 1 ]]; then # prefer-source is slow but guarantees that there will be no issues related to max path length on Windows - ${php_executable} ${composer_phar} --ignore-platform-reqs --prefer-source "$@" + ${php_executable} "${composer_phar}" --ignore-platform-reqs --prefer-source "$@" else - ${php_executable} ${composer_phar} --ignore-platform-reqs "$@" + ${php_executable} "${composer_phar}" --ignore-platform-reqs "$@" fi if [ ! ${auth_json_already_exists} = 1 ] && [ -f "${current_dir}/auth.json" ]; then diff --git a/scripts/host/configure_php_storm.sh b/scripts/host/configure_php_storm.sh index 8643e0824b4..eaaa77c1fdf 100755 --- a/scripts/host/configure_php_storm.sh +++ b/scripts/host/configure_php_storm.sh @@ -5,7 +5,7 @@ vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd) # Enable trace printing and exit on the first error set +x -cd ${vagrant_dir} +cd "${vagrant_dir}" ssh_port=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_forwarded_ssh_port") magento_host_name=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "magento_host_name") @@ -32,8 +32,8 @@ sed -i.back "s||${magento_host_name}|g" "${vagrant_dir}/.idea/deploym sed -i.back "s||${magento_host_name}|g" "${vagrant_dir}/.idea/deployment.xml" sed -i.back "s||${magento_host_name}|g" "${vagrant_dir}/.idea/.name" sed -i.back "s||${magento_host_name}|g" "${vagrant_dir}/.idea/modules.xml" -rm -rf ${vagrant_dir}/.idea/*.back -rm -f ${vagrant_dir}/.idea/.name.back +rm -rf "${vagrant_dir}/.idea/*.back" +rm -f "${vagrant_dir}/.idea/.name.back" mv "${vagrant_dir}/.idea/host_name.iml" "${vagrant_dir}/.idea/${magento_host_name}.iml" diff --git a/scripts/host/install_php.sh b/scripts/host/install_php.sh index 90918caa0a7..7d494adb807 100755 --- a/scripts/host/install_php.sh +++ b/scripts/host/install_php.sh @@ -7,13 +7,13 @@ host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") set -ex if [[ ${host_os} == "Windows" ]]; then - curl http://windows.php.net/downloads/releases/archives/php-5.6.9-nts-Win32-VC11-x86.zip -o ${vagrant_dir}/lib/php.zip - unzip -q ${vagrant_dir}/lib/php.zip -d ${vagrant_dir}/lib/php - rm -f ${vagrant_dir}/lib/php.zip + curl http://windows.php.net/downloads/releases/archives/php-5.6.9-nts-Win32-VC11-x86.zip -o "${vagrant_dir}/lib/php.zip" + unzip -q "${vagrant_dir}/lib/php.zip" -d "${vagrant_dir}/lib/php" + rm -f "${vagrant_dir}/lib/php.zip" cp "${vagrant_dir}/lib/php/php.ini-development" "${vagrant_dir}/lib/php/php.ini" sed -i.back 's|; extension_dir = "ext"|extension_dir = "ext"|g' "${vagrant_dir}/lib/php/php.ini" sed -i.back 's|;extension=php_openssl.dll|extension=php_openssl.dll|g' "${vagrant_dir}/lib/php/php.ini" - rm -rf ${vagrant_dir}/lib/php/*.back + rm -rf "${vagrant_dir}/lib/php/*.back" fi php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index ec0b47f69c4..3e3ce356890 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -21,9 +21,9 @@ else virtual_host_config=${default_virtual_host_config} fi enabled_virtual_host_config="/etc/apache2/sites-available/magento2.conf" -cp ${virtual_host_config} ${enabled_virtual_host_config} -sed -i "s||${magento_host_name}|g" ${enabled_virtual_host_config} -sed -i "s||${guest_magento_dir}|g" ${enabled_virtual_host_config} +cp "${virtual_host_config}" "${enabled_virtual_host_config}" +sed -i "s||${magento_host_name}|g" "${enabled_virtual_host_config}" +sed -i "s||${guest_magento_dir}|g" "${enabled_virtual_host_config}" a2ensite magento2.conf # Disable default virtual host @@ -39,7 +39,7 @@ if [ -f ${composer_auth_json} ]; then sudo -H -u vagrant bash -c 'mkdir /home/vagrant/.composer' fi if [ -f ${composer_auth_json} ]; then - cp ${composer_auth_json} /home/vagrant/.composer/auth.json + cp "${composer_auth_json}" "/home/vagrant/.composer/auth.json" fi fi diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 4890c15180c..f9a2cc2bfce 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -33,12 +33,12 @@ use_php7=$4 vagrant_dir="/vagrant" # Remove configs from host in case of force stop of virtual machine before linking restored ones -cd ${vagrant_dir}/etc && mv guest/.gitignore guest_gitignore.back && rm -rf guest && mkdir guest && mv guest_gitignore.back guest/.gitignore -bash ${vagrant_dir}/scripts/guest/link_configs +cd "${vagrant_dir}/etc" && mv guest/.gitignore guest_gitignore.back && rm -rf guest && mkdir guest && mv guest_gitignore.back guest/.gitignore +bash "${vagrant_dir}/scripts/guest/link_configs" # Make sure configs are restored on system halt and during reboot rm -f /etc/init.d/unlink-configs -cp ${vagrant_dir}/scripts/guest/unlink_configs /etc/init.d/unlink-configs +cp "${vagrant_dir}/scripts/guest/unlink_configs" /etc/init.d/unlink-configs if [ ! -f /etc/rc0.d/K04-unlink-configs ]; then ln -s /etc/init.d/unlink-configs /etc/rc0.d/K04-unlink-configs ln -s /etc/init.d/unlink-configs /etc/rc1.d/S04-unlink-configs From 1463d3786e8530e73ec02f8541c621854a2c35af Mon Sep 17 00:00:00 2001 From: Rico Neitzel Date: Wed, 8 Jun 2016 13:31:05 +0200 Subject: [PATCH 046/173] fixed "binary operator expected" failures --- init_project.sh | 14 +++++++------- scripts/host/composer.sh | 8 ++++---- scripts/host/get_path_to_php.sh | 2 +- scripts/provision/configure_environment.sh | 4 ++-- .../provision/configure_environment_recurring.sh | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/init_project.sh b/init_project.sh index f6efba2ebdd..00f1cde378c 100755 --- a/init_project.sh +++ b/init_project.sh @@ -24,7 +24,7 @@ if ! echo ${vagrant_plugin_list} | grep -q 'vagrant-host-shell' ; then fi # Generate random IP address and host name to prevent collisions, if not specified explicitly in local config -if [ ! -f "${vagrant_dir}/etc/config.yaml" ]; then +if [[ ! -f "${vagrant_dir}/etc/config.yaml" ]]; then cp "${config_path}.dist" "${config_path}" fi random_ip=$(( ( RANDOM % 240 ) + 12 )) @@ -46,18 +46,18 @@ while getopts 'fcp' flag; do *) error "Unexpected option ${flag}" ;; esac done -if [ ${force_project_cleaning} -eq 1 ]; then +if [[ ${force_project_cleaning} -eq 1 ]]; then vagrant destroy -f - if [ ${force_codebase_cleaning} -eq 1 ]; then mv "${vagrant_dir}/etc/guest/.gitignore" "${vagrant_dir}/etc/.gitignore.back" rm -rf "${vagrant_dir}/.vagrant" "${vagrant_dir}/etc/guest" mkdir "${vagrant_dir}/etc/guest" mv "${vagrant_dir}/etc/.gitignore.back" "${vagrant_dir}/etc/guest/.gitignore" + if [[ ${force_codebase_cleaning} -eq 1 ]]; then rm -rf "${magento_ce_dir}" fi fi -if [ ! -d ${magento_ce_dir} ]; then +if [[ ! -d ${magento_ce_dir} ]]; then if [[ ${host_os} == "Windows" ]]; then git config --global core.autocrlf false git config --global core.eol LF @@ -69,7 +69,7 @@ if [ ! -d ${magento_ce_dir} ]; then # Check out EE repository # By default EE repository is not specified and EE project is not checked out repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee") - if [ -n "${repository_url_ee}" ]; then + if [[ -n "${repository_url_ee}" ]]; then git clone ${repository_url_ee} "${magento_ee_dir}" fi fi @@ -84,10 +84,10 @@ vagrant up set +x echo "Configuring PhpStorm..." -if [ ${force_project_cleaning} -eq 1 ] && [ ${force_phpstorm_config_cleaning} -eq 1 ]; then +if [[ ${force_project_cleaning} -eq 1 ]] && [[ ${force_phpstorm_config_cleaning} -eq 1 ]]; then rm -rf "${vagrant_dir}/.idea" fi -if [ ! "$(ls -A ${vagrant_dir}/.idea)" ]; then +if [[ ! "$(ls -A "${vagrant_dir}/.idea")" ]]; then bash "${vagrant_dir}/scripts/host/configure_php_storm.sh" fi diff --git a/scripts/host/composer.sh b/scripts/host/composer.sh index c4631de1aff..f95435ae534 100755 --- a/scripts/host/composer.sh +++ b/scripts/host/composer.sh @@ -16,19 +16,19 @@ bash "${vagrant_dir}/scripts/host/check_requirements.sh" php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Setup composer if necessary -if [ ! -f ${composer_phar} ]; then +if [[ ! -f ${composer_phar} ]]; then cd "${composer_dir}" curl -sS https://getcomposer.org/installer | ${php_executable} fi # Configure composer credentials auth_json_already_exists=0 -if [ -f "${current_dir}/auth.json" ]; then +if [[ -f "${current_dir}/auth.json" ]]; then auth_json_already_exists=1 fi -if [ ! ${auth_json_already_exists} = 1 ] && [ -f ${composer_auth_json} ]; then cd "${current_dir}" +if [[ ! ${auth_json_already_exists} = 1 ]] && [[ -f ${composer_auth_json} ]]; then cp "${composer_auth_json}" "${current_dir}/auth.json" fi @@ -40,6 +40,6 @@ else ${php_executable} "${composer_phar}" --ignore-platform-reqs "$@" fi -if [ ! ${auth_json_already_exists} = 1 ] && [ -f "${current_dir}/auth.json" ]; then +if [[ ! ${auth_json_already_exists} = 1 ]] && [[ -f "${current_dir}/auth.json" ]]; then rm "${current_dir}/auth.json" fi diff --git a/scripts/host/get_path_to_php.sh b/scripts/host/get_path_to_php.sh index cc7325d90e5..659a438f642 100644 --- a/scripts/host/get_path_to_php.sh +++ b/scripts/host/get_path_to_php.sh @@ -6,7 +6,7 @@ vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd) set -ex # Find path to available PHP -if [ -f ${vagrant_dir}/lib/php/php.exe ]; then +if [[ -f ${vagrant_dir}/lib/php/php.exe ]]; then php_executable="${vagrant_dir}/lib/php/php" else php_executable="php" diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index 3e3ce356890..aef414ddf6b 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -15,7 +15,7 @@ vagrant_dir="/vagrant" # Enable Magento virtual host custom_virtual_host_config="${vagrant_dir}/etc/magento2_virtual_host.conf" default_virtual_host_config="${vagrant_dir}/etc/magento2_virtual_host.conf.dist" -if [ -f ${custom_virtual_host_config} ]; then +if [[ -f ${custom_virtual_host_config} ]]; then virtual_host_config=${custom_virtual_host_config} else virtual_host_config=${default_virtual_host_config} @@ -38,7 +38,7 @@ if [ -f ${composer_auth_json} ]; then if [ ! -d /home/vagrant/.composer ] ; then sudo -H -u vagrant bash -c 'mkdir /home/vagrant/.composer' fi - if [ -f ${composer_auth_json} ]; then + if [[ -f ${composer_auth_json} ]]; then cp "${composer_auth_json}" "/home/vagrant/.composer/auth.json" fi fi diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index f9a2cc2bfce..8f617d50c1e 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -5,7 +5,7 @@ function process_php_config () { for php_ini_path in "${php_ini_paths[@]}" do - if [ -f ${php_ini_path} ]; then + if [[ -f ${php_ini_path} ]]; then echo "date.timezone = America/Chicago" >> ${php_ini_path} sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path} sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} @@ -50,7 +50,7 @@ if [ ! -f /etc/rc0.d/K04-unlink-configs ]; then fi # Upgrade existing environment -if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then +if [[ -f ${vagrant_dir}/.idea/deployment.xml ]]; then sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "${vagrant_dir}/.idea/deployment.xml" fi From 01ddea2c12a87b5b75e9070d9ac34a47393b2a6b Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Wed, 8 Jun 2016 10:50:14 -0500 Subject: [PATCH 047/173] - Added setup and upgrade cron scripts support - Improved consistency of braces usage with conditional operators --- CHANGELOG.md | 1 + README.md | 12 +++++++----- m-switch-to-ce | 8 ++++---- m-switch-to-ee | 8 ++++---- scripts/guest/link_configs | 4 ++-- scripts/guest/log_email | 4 ++-- scripts/guest/m-reinstall | 6 ++++-- scripts/guest/unlink_configs | 4 ++-- scripts/host/configure_php_storm.sh | 2 +- scripts/host/get_host_os.sh | 8 ++++---- scripts/provision/configure_environment.sh | 6 +++--- scripts/provision/configure_environment_recurring.sh | 10 +++++----- 12 files changed, 39 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 764a4a754bf..27b12da0640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added + - Added setup and upgrade cron scripts to crontab - Added logging of all emails in HTML format to `vagrant-magento/log/email` - Added host wrapper script for bin/magento command on guest - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE diff --git a/README.md b/README.md index 039d994478f..49b2450b2e4 100755 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ Unique IP address, SSH port and domain name will be generated for each new insta ### Reset environment -It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box, vagrant project settings and PhpStorm project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) and [etc/config.yaml](etc/config.yaml.dist) will stay untouched, but guest config files (located in [etc/guest](etc/guest)) will be removed. +It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box and vagrant project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) and [etc/config.yaml](etc/config.yaml.dist) and PhpStorm settings will stay untouched, but guest config files (located in [etc/guest](etc/guest)) will be cleared. Go to 'vagrant-magento' created earlier and run in command line: @@ -245,9 +245,7 @@ Go to 'vagrant-magento' created earlier and run in command line: bash init_project.sh -f ``` -You can reset project settings and Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in [etc/config.yaml](etc/config.yaml.dist) - -Go to 'vagrant-magento' created earlier and run in command line: +It is possible to reset Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in [etc/config.yaml](etc/config.yaml.dist) ``` bash init_project.sh -fc @@ -257,6 +255,10 @@ To reset PhpStorm project configuration, in addition to `-f` specify `-p` option ``` bash init_project.sh -fp -OR +``` + +Ultimate project reset can be achieved by combining all available flags: + +``` bash init_project.sh -fcp ``` diff --git a/m-switch-to-ce b/m-switch-to-ce index 04e1c9ae85b..f573d530222 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -9,12 +9,12 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error set -ex -if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then +if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then echo "EE codebase is not available" exit 0 fi -if [ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then +if [[ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then echo "Already switched to CE" exit 0 fi @@ -27,10 +27,10 @@ git checkout composer.lock if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then # Prevent issues on Windows with incorrect symlinks to files - if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then + if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json fi - if [ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ] && [ ! -L ${magento_ce_dir}/app/etc/enterprise ]; then + if [[ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ]] && [[ ! -L ${magento_ce_dir}/app/etc/enterprise ]]; then rm ${magento_ce_dir}/app/etc/enterprise/di.xml rmdir ${magento_ce_dir}/app/etc/enterprise fi diff --git a/m-switch-to-ee b/m-switch-to-ee index 138184642af..e6ee1ad5ae4 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -9,12 +9,12 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error set -ex -if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then +if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then echo "EE codebase is not available" exit 0 fi -if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then +if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then echo "Already switched to EE" exit 0 fi @@ -26,11 +26,11 @@ cp ${magento_ee_dir}/composer.lock ${magento_ce_dir}/composer.lock if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then # Prevent issues on Windows with incorrect symlinks to files - if [ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ] && [ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then + if [[ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]] && [[ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json cp ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ${magento_ce_dir}/app/etc/aliases_to_classes_map.json fi - if [ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ] && [ -L ${magento_ce_dir}/app/etc/enterprise ]; then + if [[ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ]] && [[ -L ${magento_ce_dir}/app/etc/enterprise ]]; then rm ${magento_ce_dir}/app/etc/enterprise mkdir ${magento_ce_dir}/app/etc/enterprise cp ${magento_ee_dir}/app/etc/enterprise/di.xml ${magento_ce_dir}/app/etc/enterprise/di.xml diff --git a/scripts/guest/link_configs b/scripts/guest/link_configs index 1ce59629b23..efd1ce16798 100755 --- a/scripts/guest/link_configs +++ b/scripts/guest/link_configs @@ -5,8 +5,8 @@ function process_configs () { configs=$2 for config in "${configs[@]}" do - if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then - if [ -d ${configs_path}/${config} ] || [ -f ${configs_path}/${config} ]; then + if [[ ! -d /vagrant/etc/guest/${config} ]] && [[ ! -f /vagrant/etc/guest/${config} ]]; then + if [[ -d ${configs_path}/${config} ]] || [[ -f ${configs_path}/${config} ]]; then sudo rm -rf "${configs_path}/${config}.back" sudo cp -rp ${configs_path}/${config} "${configs_path}/${config}.back" sudo mv ${configs_path}/${config} /vagrant/etc/guest/${config} diff --git a/scripts/guest/log_email b/scripts/guest/log_email index 53c1a9b95d5..20966a85ce2 100755 --- a/scripts/guest/log_email +++ b/scripts/guest/log_email @@ -1,8 +1,8 @@ #!/usr/bin/env bash email_log_dir=$1 -if [ ! -d ${email_log_dir} ]; then - mkdir -p ${email_log_dir} +if [[ ! -d ${email_log_dir} ]]; then + mkdir -p "${email_log_dir}" fi # Construct email file path diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 73713e402df..13af91feed9 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -63,7 +63,7 @@ install_cmd="./bin/magento setup:install \ --use-rewrites=1" # Configure Rabbit MQ -if [ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ] && [ -d "${MAGENTO_ROOT}/app/code/Magento/Amqp" ]; then +if [[ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ]] && [[ -d "${MAGENTO_ROOT}/app/code/Magento/Amqp" ]]; then install_cmd="${install_cmd} \ --amqp-host=${setupOptions[amqp_host]} \ --amqp-port=${setupOptions[amqp_port]} \ @@ -78,7 +78,9 @@ php ${install_cmd} # php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} # Enable Magento cron jobs -echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - +echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run & +* * * * * php ${MAGENTO_ROOT}/update/cron.php & +* * * * * php ${MAGENTO_ROOT}/bin/magento setup:cron:run &" | crontab -u vagrant - use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") is_windows_host=${IS_WINDOWS_HOST} diff --git a/scripts/guest/unlink_configs b/scripts/guest/unlink_configs index d4ae3478757..335fe7c28b1 100755 --- a/scripts/guest/unlink_configs +++ b/scripts/guest/unlink_configs @@ -5,10 +5,10 @@ function process_configs () { configs=$2 for config in "${configs[@]}" do - if [ -L ${config_dir}/${config} ] && [ -e ${config_dir}/${config} ]; then + if [[ -L ${config_dir}/${config} ]] && [[ -e ${config_dir}/${config} ]]; then sudo rm ${config_dir}/${config} sudo mv /vagrant/etc/guest/${config} ${config_dir}/${config} - elif [ ! -e ${config_dir}/${config} ] && [ -e "${config_dir}/${config}.back" ]; then + elif [[ ! -e ${config_dir}/${config} ]] && [[ -e "${config_dir}/${config}.back" ]]; then sudo rm -rf ${config_dir}/${config} sudo cp -rp "${config_dir}/${config}.back" ${config_dir}/${config} fi diff --git a/scripts/host/configure_php_storm.sh b/scripts/host/configure_php_storm.sh index eaaa77c1fdf..3c1c7bf0684 100755 --- a/scripts/host/configure_php_storm.sh +++ b/scripts/host/configure_php_storm.sh @@ -38,7 +38,7 @@ rm -f "${vagrant_dir}/.idea/.name.back" mv "${vagrant_dir}/.idea/host_name.iml" "${vagrant_dir}/.idea/${magento_host_name}.iml" repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee") -if [ -z ${repository_url_ee} ]; then +if [[ -z ${repository_url_ee} ]]; then mv "${vagrant_dir}/.idea/vcs.ce.xml" "${vagrant_dir}/.idea/vcs.xml" rm "${vagrant_dir}/.idea/vcs.ee.xml" else diff --git a/scripts/host/get_host_os.sh b/scripts/host/get_host_os.sh index b4ebee75303..412d4aab11d 100644 --- a/scripts/host/get_host_os.sh +++ b/scripts/host/get_host_os.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -if [ "$(uname)" == "Darwin" ]; then +if [[ "$(uname)" == "Darwin" ]]; then echo "OSX" -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then +elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then echo "Linux" -elif [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then +elif [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then echo "Windows" -elif [ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]; then +elif [[ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]]; then echo "Windows" else echo "Unknown host OS" diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index aef414ddf6b..a69fa915457 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -31,11 +31,11 @@ sudo a2dissite 000-default # Configure composer composer_auth_json="${vagrant_dir}/etc/composer/auth.json" -if [ -f ${composer_auth_json} ]; then +if [[ -f ${composer_auth_json} ]]; then set +x echo "Installing composer OAuth tokens from ${composer_auth_json}..." set -x - if [ ! -d /home/vagrant/.composer ] ; then + if [[ ! -d /home/vagrant/.composer ]] ; then sudo -H -u vagrant bash -c 'mkdir /home/vagrant/.composer' fi if [[ -f ${composer_auth_json} ]]; then @@ -44,7 +44,7 @@ if [ -f ${composer_auth_json} ]; then fi # Set permissions to allow Magento codebase upload by Vagrant provision script -if [ ${use_nfs_for_synced_folders} -eq 0 ]; then +if [[ ${use_nfs_for_synced_folders} -eq 0 ]]; then chown -R vagrant:vagrant /var/www chmod -R 755 /var/www fi diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index c4e7cc99cdf..a641d6c2194 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -38,7 +38,7 @@ bash "${vagrant_dir}/scripts/guest/link_configs" # Make sure configs are restored on system halt and during reboot rm -f /etc/init.d/unlink-configs cp "${vagrant_dir}/scripts/guest/unlink_configs" /etc/init.d/unlink-configs -if [ ! -f /etc/rc0.d/K04-unlink-configs ]; then +if [[ ! -f /etc/rc0.d/K04-unlink-configs ]]; then ln -s /etc/init.d/unlink-configs /etc/rc0.d/K04-unlink-configs ln -s /etc/init.d/unlink-configs /etc/rc1.d/S04-unlink-configs ln -s /etc/init.d/unlink-configs /etc/rc2.d/S04-unlink-configs @@ -57,14 +57,14 @@ fi php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) process_php_config ${php_ini_paths} -if [ ${use_php7} -eq 1 ]; then +if [[ ${use_php7} -eq 1 ]]; then update-alternatives --set php /usr/bin/php7.0 - if [ -d "/etc/php/5.6" ]; then + if [[ -d "/etc/php/5.6" ]]; then a2dismod php5.6 fi a2enmod php7.0 else - if [ ! -d "/etc/php/5.6" ]; then + if [[ ! -d "/etc/php/5.6" ]]; then init_php56 fi update-alternatives --set php /usr/bin/php5.6 && a2dismod php7.0 && a2enmod php5.6 @@ -75,7 +75,7 @@ service apache2 restart #end Setup PHP # Enable email logging -if [ ${use_php7} -eq 1 ]; then +if [[ ${use_php7} -eq 1 ]]; then php_ini_file="/etc/php/7.0/cli/php.ini" else php_ini_file="/etc/php/5.6/cli/php.ini" From fa14504694c55fe707393900d21a4784691ba5a7 Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Wed, 8 Jun 2016 17:27:44 -0500 Subject: [PATCH 048/173] Varnish Support - Works now by invoking vagrant reload or by running "m-varnish -c enable" command. --- CHANGELOG.md | 1 + README.md | 2 +- etc/config.yaml.dist | 12 ++++-- m-varnish | 41 +++++++++++++++++++ .../configure_varnish | 20 +++++++++ scripts/guest/m-reinstall | 3 -- scripts/provision/configure_environment.sh | 9 ---- .../configure_environment_recurring.sh | 12 ++++++ 8 files changed, 84 insertions(+), 16 deletions(-) create mode 100755 m-varnish rename scripts/guest/{m-reinstall-scripts => }/configure_varnish (79%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92d20d7d08f..c7b9b205e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE - Added ability to choose if PhpStorm configs should be removed during project reinitialization - Added ability to switch PHP version without destroying the project ("vagrant reload" is required) + - Added ability to use Varnish full page caching automatically. (Using "vagrant reload" or m-varnish script) ## [v2.0.0] - 2016-02-05 diff --git a/README.md b/README.md index 94233fd5249..0a9364ccf9f 100755 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ PHP version will be applied after "vagrant reload". ### Activating Varnish Set "use_varnish: 1" to use varnish along apache in [config.yaml](etc/config.yaml.dist). -Running m-reinstall script will apply your preference. +Running vagrant reload will apply your preference. Or by using m-varnish script. It will use default file etc/magento2_default_varnish.vcl.dist generated from a Magento instance. Varnish Version: 3.0.5 diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index ed9db04c165..0ce82b1b2d8 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -1,20 +1,26 @@ repository_url: + # [Changeable: init-project -c] ce: "git@github.com:magento/magento2.git" ee: "" guest: - # NFS will be used for folder synchronization on *nix and OSX hosts by default + # [Changeable: init-project -f] + # NFS will be used for folder synchronization on *nix and OSX hosts by default. use_nfs: 1 - # Default is 2Gb, around 3Gb is necessary to run functional tests + # Default is 2Gb, around 3Gb is necessary to run functional tests. + # [Changeable: vagrant reload] memory: 2048 ip_address: "192.168.10.2" forwarded_ssh_port: 3000 environment: - # If set to 0, PHP 5 will be installed. [Changeable: vagrant reload] + # [Changeable: vagrant reload] + # If set to 0, PHP 5 will be installed. use_php7: 1 composer_prefer_source: 0 use_varnish: 0 magento: + # [Changeable: init-project -f] host_name: "magento2.vagrant2" + # [Changeable: m-reinstall] admin_frontname: "admin" language: "en_US" timezone: "America/Chicago" diff --git a/m-varnish b/m-varnish new file mode 100755 index 00000000000..11906bf106c --- /dev/null +++ b/m-varnish @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -ex + +# Get args +while getopts 'fh:c:' flag; do + case "${flag}" in + h) help=1 ;; + c) command=$OPTARG ;; + f) force_restart_services=1 ;; + *) help=1 ;; + esac +done + +if [ $help ]; then + echo "Usage: ./m-varnish -c enable/disable (-f to force restart services)" + exit 0 +fi + +# Check if user created config.yaml file +if [ ! -f ./etc/config.yaml ]; then + echo "Please make sure you have create a config.yaml file copy from etc/config.yaml.dist" + exit 0 +fi + +if [[ $command == "enable" ]]; then + sed -ie "s/use_varnish:.*/use_varnish: 1/" ./etc/config.yaml +elif [[ $command == "disable" ]]; then + sed -ie "s/use_varnish:.*/use_varnish: 0/" ./etc/config.yaml +else + echo "Usage: ./m-varnish -c enable/disable (-f to force restart services)" + exit 0 +fi + +vagrant_dir=$(cd "$(dirname "$0")"; pwd) +cd ${vagrant_dir} +if [[ $force_restart_services == 1 ]]; then + vagrant ssh -c "sudo bash /vagrant/scripts/guest/configure_varnish -f" +else + vagrant ssh -c "sudo bash /vagrant/scripts/guest/configure_varnish" +fi diff --git a/scripts/guest/m-reinstall-scripts/configure_varnish b/scripts/guest/configure_varnish similarity index 79% rename from scripts/guest/m-reinstall-scripts/configure_varnish rename to scripts/guest/configure_varnish index 104a039f2b1..761cde541da 100644 --- a/scripts/guest/m-reinstall-scripts/configure_varnish +++ b/scripts/guest/configure_varnish @@ -3,6 +3,14 @@ # Enable trace printing and exit on the first error set -ex +# Get args +while getopts 'f' flag; do + case "${flag}" in + f) force_restart_services=1 ;; + *) error "Unexpected option ${flag}" ;; + esac +done + # Init environment variables vagrant_dir="/vagrant" @@ -29,6 +37,7 @@ if [ $use_varnish -eq 1 ]; then mysql -D magento -e "INSERT INTO core_config_data ( scope, scope_id, path, value ) VALUES ( 'default', '0', 'system/full_page_cache/caching_application', '2' ) + ON DUPLICATE KEY UPDATE value = 2 ;" else @@ -45,9 +54,20 @@ else sudo sed -ie "s/Listen 8080/Listen 80/" /etc/apache2/ports.conf restart_services=1 fi + + # Update Magento database to not use varnish FPC + mysql -D magento -e "INSERT INTO core_config_data + ( scope, scope_id, path, value ) VALUES + ( 'default', '0', 'system/full_page_cache/caching_application', '1' ) + ON DUPLICATE KEY UPDATE value = 1 + ;" fi # Check if need restart services +if [[ $force_restart_services == 1 ]]; then + echo "Force restarting Apache and Varnish" + restart_services=1 +fi if [ $restart_services -eq 1 ]; then if [ "$(ps -ax | pgrep varnish)" ]; then sudo pkill varnishd diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 562c20f728f..73713e402df 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -77,9 +77,6 @@ php ${install_cmd} # Comment out the line above and uncomment the one below to debug Magento Setup script # php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} -# Configure Varnish FPC, if enabled -sh ${vagrant_dir}/scripts/guest/m-reinstall-scripts/configure_varnish - # Enable Magento cron jobs echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant - diff --git a/scripts/provision/configure_environment.sh b/scripts/provision/configure_environment.sh index 7f67241be01..ec0b47f69c4 100755 --- a/scripts/provision/configure_environment.sh +++ b/scripts/provision/configure_environment.sh @@ -29,15 +29,6 @@ a2ensite magento2.conf # Disable default virtual host sudo a2dissite 000-default -# Copy varnish vcl file -custom_vcl_config="${vagrant_dir}/etc/magento2_default_varnish.vcl" -default_vcl_config="${vagrant_dir}/etc/magento2_default_varnish.vcl.dist" -if [ -f ${custom_vcl_config} ]; then - cp ${custom_vcl_config} /etc/varnish/default.vcl -else - cp ${default_vcl_config} /etc/varnish/default.vcl -fi - # Configure composer composer_auth_json="${vagrant_dir}/etc/composer/auth.json" if [ -f ${composer_auth_json} ]; then diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 4890c15180c..0ae3b5d4d80 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -54,6 +54,18 @@ if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "${vagrant_dir}/.idea/deployment.xml" fi +# Copy varnish vcl file +custom_vcl_config="${vagrant_dir}/etc/magento2_default_varnish.vcl" +default_vcl_config="${vagrant_dir}/etc/magento2_default_varnish.vcl.dist" +if [ -f ${custom_vcl_config} ]; then + cp ${custom_vcl_config} /etc/varnish/default.vcl +else + cp ${default_vcl_config} /etc/varnish/default.vcl +fi + +# Configure Varnish FPC, if enabled +bash ${vagrant_dir}/scripts/guest/configure_varnish -f + # Setup PHP php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) process_php_config ${php_ini_paths} From 235f943b27428c7616a5373f2e2e03275b73406b Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Thu, 9 Jun 2016 12:10:28 -0500 Subject: [PATCH 049/173] Varnish Support - Changed name. - Made script executable. - Cache is cleared now after restarting services. --- etc/config.yaml.dist | 12 ++++----- m-varnish | 12 ++++----- ...{configure_varnish => m-configure_varnish} | 27 +++++++++---------- .../configure_environment_recurring.sh | 2 +- 4 files changed, 25 insertions(+), 28 deletions(-) rename scripts/guest/{configure_varnish => m-configure_varnish} (71%) mode change 100644 => 100755 diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index 0ce82b1b2d8..e962f6e60da 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -1,26 +1,26 @@ repository_url: - # [Changeable: init-project -c] + # [To apply changes: init-project -c] ce: "git@github.com:magento/magento2.git" ee: "" guest: - # [Changeable: init-project -f] + # [To apply changes: init-project -f] # NFS will be used for folder synchronization on *nix and OSX hosts by default. use_nfs: 1 # Default is 2Gb, around 3Gb is necessary to run functional tests. - # [Changeable: vagrant reload] + # [To apply changes: vagrant reload] memory: 2048 ip_address: "192.168.10.2" forwarded_ssh_port: 3000 environment: - # [Changeable: vagrant reload] + # [To apply changes: vagrant reload] # If set to 0, PHP 5 will be installed. use_php7: 1 composer_prefer_source: 0 use_varnish: 0 magento: - # [Changeable: init-project -f] + # [To apply changes: init-project -f] host_name: "magento2.vagrant2" - # [Changeable: m-reinstall] + # [To apply changes: m-reinstall] admin_frontname: "admin" language: "en_US" timezone: "America/Chicago" diff --git a/m-varnish b/m-varnish index 11906bf106c..ec71d6ee740 100755 --- a/m-varnish +++ b/m-varnish @@ -1,7 +1,5 @@ #!/usr/bin/env bash -set -ex - # Get args while getopts 'fh:c:' flag; do case "${flag}" in @@ -12,13 +10,13 @@ while getopts 'fh:c:' flag; do esac done -if [ $help ]; then +if [[ $help ]]; then echo "Usage: ./m-varnish -c enable/disable (-f to force restart services)" exit 0 fi # Check if user created config.yaml file -if [ ! -f ./etc/config.yaml ]; then +if [[ ! -f ./etc/config.yaml ]]; then echo "Please make sure you have create a config.yaml file copy from etc/config.yaml.dist" exit 0 fi @@ -35,7 +33,9 @@ fi vagrant_dir=$(cd "$(dirname "$0")"; pwd) cd ${vagrant_dir} if [[ $force_restart_services == 1 ]]; then - vagrant ssh -c "sudo bash /vagrant/scripts/guest/configure_varnish -f" + vagrant ssh -c "m-configure_varnish -f" else - vagrant ssh -c "sudo bash /vagrant/scripts/guest/configure_varnish" + vagrant ssh -c "m-configure_varnish" fi + +echo "Done." diff --git a/scripts/guest/configure_varnish b/scripts/guest/m-configure_varnish old mode 100644 new mode 100755 similarity index 71% rename from scripts/guest/configure_varnish rename to scripts/guest/m-configure_varnish index 761cde541da..6db2e271b08 --- a/scripts/guest/configure_varnish +++ b/scripts/guest/m-configure_varnish @@ -1,6 +1,5 @@ #!/usr/bin/env bash -# Enable trace printing and exit on the first error set -ex # Get args @@ -17,18 +16,18 @@ vagrant_dir="/vagrant" # Configure Varnish if enabled in config restart_services=0 use_varnish=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_use_varnish") -if [ $use_varnish -eq 1 ]; then +if [[ $use_varnish == 1 ]]; then # Configure apache files to be ready for varnish - if [ -z "$(grep "VirtualHost\s\*:8080" /etc/apache2/sites-enabled/magento2.conf)" ]; then + if [[ -z "$(grep "VirtualHost\s\*:8080" /etc/apache2/sites-enabled/magento2.conf)" ]]; then sudo sed -ie "s//" /etc/apache2/sites-enabled/magento2.conf restart_services=1 fi - if [ -z "$(grep "VirtualHost\s\*:8080" /etc/apache2/sites-available/magento2.conf)" ]; then + if [[ -z "$(grep "VirtualHost\s\*:8080" /etc/apache2/sites-available/magento2.conf)" ]]; then sudo sed -ie "s//" /etc/apache2/sites-available/magento2.conf restart_services=1 fi - if [ -z "$(grep "Listen\s8080" /etc/apache2/ports.conf)" ]; then + if [[ -z "$(grep "Listen\s8080" /etc/apache2/ports.conf)" ]]; then sudo sed -ie "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf restart_services=1 fi @@ -42,15 +41,15 @@ if [ $use_varnish -eq 1 ]; then else # Configure apache files to run without varnish - if [ -z "$(grep "VirtualHost\s\*:80\b" /etc/apache2/sites-enabled/magento2.conf)" ]; then + if [[ -z "$(grep "VirtualHost\s\*:80\b" /etc/apache2/sites-enabled/magento2.conf)" ]]; then sudo sed -ie "s//" /etc/apache2/sites-enabled/magento2.conf restart_services=1 fi - if [ -z "$(grep "VirtualHost\s\*:80\b" /etc/apache2/sites-available/magento2.conf)" ]; then + if [[ -z "$(grep "VirtualHost\s\*:80\b" /etc/apache2/sites-available/magento2.conf)" ]]; then sudo sed -ie "s//" /etc/apache2/sites-available/magento2.conf restart_services=1 fi - if [ -z "$(grep "Listen\s80\b" /etc/apache2/ports.conf)" ]; then + if [[ -z "$(grep "Listen\s80\b" /etc/apache2/ports.conf)" ]]; then sudo sed -ie "s/Listen 8080/Listen 80/" /etc/apache2/ports.conf restart_services=1 fi @@ -68,15 +67,13 @@ if [[ $force_restart_services == 1 ]]; then echo "Force restarting Apache and Varnish" restart_services=1 fi -if [ $restart_services -eq 1 ]; then - if [ "$(ps -ax | pgrep varnish)" ]; then +if [[ $restart_services == 1 ]]; then + if [[ "$(ps -ax | pgrep varnish)" ]]; then sudo pkill varnishd fi - if [ "$(ps -ax | pgrep apache2)" ]; then - sudo apache2ctl stop - fi - sudo apache2ctl start - if [ $use_varnish -eq 1 ]; then + sudo service apache2 restart + if [[ $use_varnish == 1 ]]; then sudo varnishd -f /etc/varnish/default.vcl fi + bash "${vagrant_dir}/scripts/guest/m-clear-cache" fi diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index b4427dba724..53d29d80143 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -63,7 +63,7 @@ else fi # Configure Varnish FPC, if enabled -bash ${vagrant_dir}/scripts/guest/configure_varnish -f +bash ${vagrant_dir}/scripts/guest/m-configure_varnish -f # Setup PHP php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) From c67dd1066a31d1de36993c8fefe65fe821f6c389 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Thu, 9 Jun 2016 17:46:13 -0500 Subject: [PATCH 050/173] Fixed php include path for running unit tests on guest --- scripts/provision/configure_environment_recurring.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index a641d6c2194..1f065eec5ad 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -11,6 +11,9 @@ function process_php_config () { sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path} sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path} sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path} + + # TODO: Fix for a bug, should be removed in 3.0 + sed -i "s|:/vendor/phpunit/phpunit|:${guest_magento_dir}/vendor/phpunit/phpunit|g" ${php_ini_path} fi done } @@ -28,6 +31,7 @@ function init_php56 () { # Enable trace printing and exit on the first error set +x +guest_magento_dir=$2 use_php7=$4 vagrant_dir="/vagrant" From 2f118d3654c781a4132641ff5ac5a6d4a0f988f4 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Sat, 11 Jun 2016 00:59:56 -0500 Subject: [PATCH 051/173] Added script for upgrading php to 7.0.7 --- Vagrantfile | 5 +++ .../upgrade_environment_recurring.sh | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 scripts/provision/upgrade_environment_recurring.sh diff --git a/Vagrantfile b/Vagrantfile index 4fe51ba16ee..0547b4c89ca 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -75,6 +75,11 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile" end + config.vm.provision "upgrade_environment_recurring", type: "shell", run: "always" do |s| + s.path = "scripts/provision/upgrade_environment_recurring.sh" + s.args = shell_script_args + end + config.vm.provision "configure_environment", type: "shell" do |s| s.path = "scripts/provision/configure_environment.sh" s.args = shell_script_args diff --git a/scripts/provision/upgrade_environment_recurring.sh b/scripts/provision/upgrade_environment_recurring.sh new file mode 100755 index 00000000000..873a5922825 --- /dev/null +++ b/scripts/provision/upgrade_environment_recurring.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Enable trace printing and exit on the first error +set -ex + +use_php7=$4 + +# Upgrade for vagrant box paliarush/magento2.ubuntu v1.1.0 +if [[ ${use_php7} -eq 1 ]]; then + if /usr/bin/php7.0 -v | grep -q '7.0.5' ; then + apt-get update + a2dismod php7.0 + rm -rf /etc/php/7.0/apache2 + export DEBIAN_FRONTEND=noninteractive + apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install php7.0 php7.0-mcrypt php7.0-curl php7.0-cli php7.0-mysql php7.0-gd php7.0-intl php7.0-xsl php7.0-bcmath php7.0-mbstring php7.0-soap php7.0-zip libapache2-mod-php7.0 + a2enmod php7.0 + + # Install XDebug + cd /usr/lib + rm -rf xdebug + git clone git://github.com/xdebug/xdebug.git + cd xdebug + phpize + ./configure --enable-xdebug + make + make install + + rm -rf /etc/php/7.0/apache2 + ln -s /etc/php/7.0/cli /etc/php/7.0/apache2 + + # Restart Apache + service apache2 restart + fi +fi \ No newline at end of file From f7ef41c7803a78f8f562683d8879bc1cf3ca8eb5 Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Sun, 12 Jun 2016 15:44:51 -0500 Subject: [PATCH 052/173] Varnish Support - Changed the way the command works. - m-varnish command now accounts for backwards compatibility. - m-varnish command now works on guest. --- README.md | 2 + m-varnish | 38 +------------------ ...{m-configure_varnish => configure_varnish} | 2 - scripts/guest/m-varnish | 29 ++++++++++++++ .../configure_environment_recurring.sh | 2 +- 5 files changed, 33 insertions(+), 40 deletions(-) rename scripts/guest/{m-configure_varnish => configure_varnish} (99%) create mode 100755 scripts/guest/m-varnish diff --git a/README.md b/README.md index 088325eeaf0..6288112438b 100755 --- a/README.md +++ b/README.md @@ -238,6 +238,8 @@ Running vagrant reload will apply your preference. Or by using m-varnish script. It will use default file etc/magento2_default_varnish.vcl.dist generated from a Magento instance. Varnish Version: 3.0.5 +Note: command m-varnish with arguments disable or enable is also available in guest or host to enable or disable varnish without reloading machine. + ### Multiple Magento instances To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host. diff --git a/m-varnish b/m-varnish index ec71d6ee740..7010b5e7760 100755 --- a/m-varnish +++ b/m-varnish @@ -1,41 +1,5 @@ #!/usr/bin/env bash -# Get args -while getopts 'fh:c:' flag; do - case "${flag}" in - h) help=1 ;; - c) command=$OPTARG ;; - f) force_restart_services=1 ;; - *) help=1 ;; - esac -done - -if [[ $help ]]; then - echo "Usage: ./m-varnish -c enable/disable (-f to force restart services)" - exit 0 -fi - -# Check if user created config.yaml file -if [[ ! -f ./etc/config.yaml ]]; then - echo "Please make sure you have create a config.yaml file copy from etc/config.yaml.dist" - exit 0 -fi - -if [[ $command == "enable" ]]; then - sed -ie "s/use_varnish:.*/use_varnish: 1/" ./etc/config.yaml -elif [[ $command == "disable" ]]; then - sed -ie "s/use_varnish:.*/use_varnish: 0/" ./etc/config.yaml -else - echo "Usage: ./m-varnish -c enable/disable (-f to force restart services)" - exit 0 -fi - vagrant_dir=$(cd "$(dirname "$0")"; pwd) cd ${vagrant_dir} -if [[ $force_restart_services == 1 ]]; then - vagrant ssh -c "m-configure_varnish -f" -else - vagrant ssh -c "m-configure_varnish" -fi - -echo "Done." +vagrant ssh -c "m-varnish ${@}" diff --git a/scripts/guest/m-configure_varnish b/scripts/guest/configure_varnish similarity index 99% rename from scripts/guest/m-configure_varnish rename to scripts/guest/configure_varnish index 6db2e271b08..f67996008fb 100755 --- a/scripts/guest/m-configure_varnish +++ b/scripts/guest/configure_varnish @@ -1,7 +1,5 @@ #!/usr/bin/env bash -set -ex - # Get args while getopts 'f' flag; do case "${flag}" in diff --git a/scripts/guest/m-varnish b/scripts/guest/m-varnish new file mode 100755 index 00000000000..8fd41142994 --- /dev/null +++ b/scripts/guest/m-varnish @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if [[ $1 == "help" ]]; then + echo "Usage: ./m-varnish enable/disable" + exit 0 +fi + +# Check if user created config.yaml file +if [[ ! -f /vagrant/etc/config.yaml ]]; then + echo "Please make sure you have create a config.yaml file copy from etc/config.yaml.dist" + exit 1 +fi + +if [[ -z "$(grep "use_varnish:" /vagrant/etc/config.yaml)" ]]; then + sed -i '/environment:/a \ \ use_varnish: 0' /vagrant/etc/config.yaml +fi + +if [[ $1 == "enable" ]]; then + sed -ie "s/use_varnish:.*/use_varnish: 1/" /vagrant/etc/config.yaml +elif [[ $1 == "disable" ]]; then + sed -ie "s/use_varnish:.*/use_varnish: 0/" /vagrant/etc/config.yaml +else + echo "Usage: ./m-varnish enable/disable" + exit 1 +fi + +configure_varnish + +echo "Done." diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 6b544a8e4f5..a3b0aa4ef94 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -67,7 +67,7 @@ else fi # Configure Varnish FPC, if enabled -bash ${vagrant_dir}/scripts/guest/m-configure_varnish -f +configure_varnish -f # Setup PHP php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) From 64963ea941ef7ec6c9897934d4ad00c3c3586f12 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 13 Jun 2016 13:56:12 -0500 Subject: [PATCH 053/173] Add ElasticSearch support (EE only) #49 --- etc/config.yaml.dist | 2 ++ scripts/guest/m-reinstall | 3 +++ scripts/guest/m-search-engine | 24 ++++++++++++++++++ scripts/guest/update_magento_config | 13 ++++++++++ .../configure_environment_recurring.sh | 25 ++++++++++++++++--- 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100755 scripts/guest/m-search-engine create mode 100755 scripts/guest/update_magento_config diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index 84c916e9b53..fba8abacf31 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -12,6 +12,8 @@ environment: # If set to 0, PHP 5 will be installed. [Changeable: vagrant reload] use_php7: 1 composer_prefer_source: 0 + # Possible values: mysql, elasticsearch. Current option will enforce search engine change on every magento reinstall + search_engine: "mysql" magento: host_name: "magento2.vagrant2" admin_frontname: "admin" diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 13af91feed9..01d11c7192a 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -88,6 +88,9 @@ if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then chown -R vagrant:vagrant ${MAGENTO_ROOT} fi +# Configure search engine according to config.yaml +m-search-engine + # Generate XSD references for PHP Storm php bin/magento dev:urn-catalog:generate /vagrant/.idea/misc.xml sed -i "s|${MAGENTO_ROOT}|${MAGENTO_ROOT_HOST}|g" "/vagrant/.idea/misc.xml" diff --git a/scripts/guest/m-search-engine b/scripts/guest/m-search-engine new file mode 100755 index 00000000000..05e6c8ab497 --- /dev/null +++ b/scripts/guest/m-search-engine @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Enable trace printing and exit on the first error +set -ex + +vagrant_dir="/vagrant" + +# TODO: Make it possible to pass arguments from the outside + +# Configure search engine +search_engine=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_search_engine") +if [[ ${search_engine} == "elasticsearch" ]]; then + update_magento_config 'catalog/search/engine' 'elasticsearch' + update_magento_config 'catalog/search/elasticsearch_server_hostname' 'localhost' + update_magento_config 'catalog/search/elasticsearch_server_port' '9200' + update_magento_config 'catalog/search/elasticsearch_index_prefix' 'magento2' + update_magento_config 'catalog/search/elasticsearch_enable_auth' '0' + update_magento_config 'catalog/search/elasticsearch_server_timeout' '15' +elif [[ ${search_engine} == "mysql" ]]; then + update_magento_config 'catalog/search/engine' 'mysql' +fi +# End configure search engine + +m-clear-cache diff --git a/scripts/guest/update_magento_config b/scripts/guest/update_magento_config new file mode 100755 index 00000000000..e96c6193ddf --- /dev/null +++ b/scripts/guest/update_magento_config @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Enable trace printing and exit on the first error +set -ex + +config_path=$1 +config_value=$2 + +mysql -D magento -e "INSERT INTO core_config_data + ( scope, scope_id, path, value ) VALUES + ( 'default', '0', '${config_path}', '${config_value}' ) + ON DUPLICATE KEY UPDATE value = '${config_value}' +;" diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 1f065eec5ad..00e08470221 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -19,15 +19,23 @@ function process_php_config () { } function init_php56 () { - sudo add-apt-repository ppa:ondrej/php - sudo apt-get update - sudo apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 + add-apt-repository ppa:ondrej/php + apt-get update + apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 echo ' xdebug.max_nesting_level=200 xdebug.remote_enable=1 xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini } +function isServiceAvailable() { + if service --status-all | grep -Fq ${1}; then + echo 1 + else + echo 0 + fi +} + # Enable trace printing and exit on the first error set +x @@ -78,6 +86,17 @@ fi service apache2 restart #end Setup PHP +# Set up elastic search +is_elastic_search_installed="$(isServiceAvailable elasticsearch)" +if [[ ${is_elastic_search_installed} -eq 0 ]]; then + apt-get update + apt-get install -y openjdk-7-jre + wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb + dpkg -i elasticsearch-1.7.2.deb + update-rc.d elasticsearch defaults +fi +# End set up elastic search + # Enable email logging if [[ ${use_php7} -eq 1 ]]; then php_ini_file="/etc/php/7.0/cli/php.ini" From 96f3800603ccf7b2605a2e7a8b8ffc6472e95f8d Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Sun, 19 Jun 2016 23:29:16 -0500 Subject: [PATCH 054/173] - Added ability to force switch to CE or EE edition - EE is installed by default if EE repository is specified in config.yaml --- CHANGELOG.md | 2 ++ README.md | 3 +++ Vagrantfile | 2 -- init_project.sh | 6 ++++++ m-switch-to-ce | 14 ++++++++++++-- m-switch-to-ee | 14 ++++++++++++-- scripts/guest/m-reinstall | 2 +- 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b12da0640..bd4f4ccd05b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) - Changed requirement for minimum box version from 1.0 to 1.1 - Upgraded PHP 5.5.9 to PHP 5.6 + - When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml.dist](etc/config.yaml.dist) ### Fixed @@ -29,6 +30,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added ability to modify guest config files (PHP, Apache etc) directly from host IDE - Added ability to choose if PhpStorm configs should be removed during project reinitialization - Added ability to switch PHP version without destroying the project ("vagrant reload" is required) + - Added ability to do force switch to CE or EE (even if already switched to target edition) ## [v2.0.0] - 2016-02-05 diff --git a/README.md b/README.md index 49b2450b2e4..527498bc5d6 100755 --- a/README.md +++ b/README.md @@ -168,6 +168,9 @@ bash m-switch-to-ce OR bash m-switch-to-ee ``` + +Force switch can be done using `-f` flag even if already switched to the target edition. May be helpful to relink EE modules after switching between branches. + :information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key. ### Update Composer dependencies diff --git a/Vagrantfile b/Vagrantfile index 0547b4c89ca..f359628de7b 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -101,8 +101,6 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.provision "guest_remove_compressed_code", type: "shell", inline: "rm -f /vagrant/scripts/host/magento2ce.tar" end - config.vm.provision "install_magento", type: "shell", inline: "m-reinstall" - # Host manager plugin configuration config.hostmanager.enabled = true config.hostmanager.manage_host = true diff --git a/init_project.sh b/init_project.sh index d3f74aa8da6..18813f60adc 100755 --- a/init_project.sh +++ b/init_project.sh @@ -83,6 +83,12 @@ bash "${vagrant_dir}/scripts/host/composer.sh" install cd "${vagrant_dir}" vagrant up +if [[ -n "${repository_url_ee}" ]]; then + bash "${vagrant_dir}/m-switch-to-ee" -f +else + bash "${vagrant_dir}/m-switch-to-ce" -f +fi + set +x echo "Configuring PhpStorm..." if [[ ${force_project_cleaning} -eq 1 ]] && [[ ${force_phpstorm_config_cleaning} -eq 1 ]]; then diff --git a/m-switch-to-ce b/m-switch-to-ce index f573d530222..c6ceedee73a 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -10,12 +10,22 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") set -ex if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then + set +x echo "EE codebase is not available" exit 0 fi -if [[ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then - echo "Already switched to CE" +force_switch=0 +while getopts 'f' flag; do + case "${flag}" in + f) force_switch=1 ;; + *) error "Unexpected option ${flag}" ;; + esac +done + +if [[ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]] && [[ ${force_switch} -eq 0 ]]; then + set +x + echo "Already switched to CE. Use 'm-switch-to-ce -f' to switch anyway." exit 0 fi diff --git a/m-switch-to-ee b/m-switch-to-ee index e6ee1ad5ae4..7637030f4da 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -10,12 +10,22 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") set -ex if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then + set +x echo "EE codebase is not available" exit 0 fi -if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then - echo "Already switched to EE" +force_switch=0 +while getopts 'f' flag; do + case "${flag}" in + f) force_switch=1 ;; + *) error "Unexpected option ${flag}" ;; + esac +done + +if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]] && [[ ${force_switch} -eq 0 ]]; then + set +x + echo "Already switched to EE. Use 'm-switch-to-ce -f' to switch anyway." exit 0 fi diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 13af91feed9..1f94cbfe681 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -63,7 +63,7 @@ install_cmd="./bin/magento setup:install \ --use-rewrites=1" # Configure Rabbit MQ -if [[ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ]] && [[ -d "${MAGENTO_ROOT}/app/code/Magento/Amqp" ]]; then +if [[ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ]]; then install_cmd="${install_cmd} \ --amqp-host=${setupOptions[amqp_host]} \ --amqp-port=${setupOptions[amqp_port]} \ From a5f16b2c398c958adb0039a3e615bb72fdf2bfc2 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Sun, 19 Jun 2016 23:35:05 -0500 Subject: [PATCH 055/173] Install varnish if it is not installed automatically on vagrant reload --- .../provision/configure_environment_recurring.sh | 2 +- .../provision/upgrade_environment_recurring.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index a3b0aa4ef94..172b47e1ee1 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -67,7 +67,7 @@ else fi # Configure Varnish FPC, if enabled -configure_varnish -f +bash "${vagrant_dir}/scripts/guest/configure_varnish" -f # Setup PHP php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini ) diff --git a/scripts/provision/upgrade_environment_recurring.sh b/scripts/provision/upgrade_environment_recurring.sh index 873a5922825..47ac31fbb38 100755 --- a/scripts/provision/upgrade_environment_recurring.sh +++ b/scripts/provision/upgrade_environment_recurring.sh @@ -1,5 +1,13 @@ #!/usr/bin/env bash +function isServiceAvailable() { + if service --status-all | grep -Fq ${1}; then + echo 1 + else + echo 0 + fi +} + # Enable trace printing and exit on the first error set -ex @@ -31,4 +39,11 @@ if [[ ${use_php7} -eq 1 ]]; then # Restart Apache service apache2 restart fi +fi + +# Install varnish if not installed +is_varnish_installed="$(isServiceAvailable varnish)" +if [[ ${is_varnish_installed} -eq 0 ]]; then + apt-get update + apt-get install -y varnish fi \ No newline at end of file From 906a3582db6cc02608d3c7a6fc969a4661600b62 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 20 Jun 2016 12:30:23 -0500 Subject: [PATCH 056/173] Install varnish if it is not installed automatically on vagrant reload --- scripts/provision/upgrade_environment_recurring.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/provision/upgrade_environment_recurring.sh b/scripts/provision/upgrade_environment_recurring.sh index 47ac31fbb38..ceb1ea4a68c 100755 --- a/scripts/provision/upgrade_environment_recurring.sh +++ b/scripts/provision/upgrade_environment_recurring.sh @@ -13,6 +13,9 @@ set -ex use_php7=$4 +# Delete obsolete repository +sudo rm -f /etc/apt/sources.list.d/ondrej-php-7_0-trusty.list + # Upgrade for vagrant box paliarush/magento2.ubuntu v1.1.0 if [[ ${use_php7} -eq 1 ]]; then if /usr/bin/php7.0 -v | grep -q '7.0.5' ; then From a8ea4e5c1a8991f3c5305481cc9f1bc53e0b8549 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 20 Jun 2016 15:16:34 -0500 Subject: [PATCH 057/173] Added note about fixing broken project in PhpStorm --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 734a9f60dbc..c7ab7360b15 100755 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ Note, that semantic versioning is only used for `x.0` branches (not for `develop 1. ![](docs/images/linux-icon.png)![](docs/images/osx-icon.png) On OSX and \*nix hosts NFS will be used by default to sync your project files with guest. On some hosts Vagrant cannot configure NFS properly, in this case it is possible to deploy project without NFS by setting `use_nfs` option in [config.yaml](etc/config.yaml.dist) to `0`
1. ![](docs/images/windows-icon.png) On Windows hosts you might face `Composer Install Error: ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)` exception during `composer install`. This can be fixed in 2 ways: decrease path length to the project directory or set `composer_prefer_source` option in [config.yaml](etc/config.yaml.dist) to `1` 1. Make sure that you used `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`) + 1. If project opened in PhpStorm looks broken, close PhpStorm and remove `vagrant-magento/.idea`. After opening project in PhpStorm again everything should look good 1. If code is not synchronized properly on Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly), make sure that PhpStorm is running before making any changes in the code. This is important because otherwise PhpStorm will not be able to detect changes and upload them to the guest machine 1. Please make sure that currently installed software, specified in [requirements section](#requirements), meets minimum version requirement 1. If MySQL fails to start and Magento reinstallation fails with `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)`, try to run login to virtual machine using `vagrant ssh` and then run `sudo dpkg-reconfigure mysql-server-5.6`, then `sudo service mysql restart.` From 7ca93240acf8d7b152fe9263e626008aac6f85f1 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Thu, 21 Apr 2016 09:24:52 -0500 Subject: [PATCH 058/173] - On Windows use m-reinstall instead of m-switch-to-* in init_project.sh - Improved stability of m-clear-cache and m-reinstall scripts - Fixed debugginfor web API functional tests (#12) --- CHANGELOG.md | 2 +- CONTRIBUTING.md | 2 +- init_project.sh | 19 ++++++---- m-switch-to-ce | 20 ++++++----- m-switch-to-ee | 4 +-- scripts/guest/m-clear-cache | 36 ++++++++++++++----- scripts/guest/m-reinstall | 14 +++++--- scripts/host/configure_php_storm.sh | 2 +- .../configure_environment_recurring.sh | 4 ++- 9 files changed, 68 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24413f57c27..0e12ab49784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side) - Changed requirement for minimum box version from 1.0 to 1.1 - Upgraded PHP 5.5.9 to PHP 5.6 - - When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml.dist](etc/config.yaml.dist) + - When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml.dist](etc/config.yaml.dist). Not supported on Windows hosts ### Fixed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 832c5682a44..b7de76d26fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -Everyone is welcome to contribute improvements and fixes to this project. There are no specific requirements, just create a pull request with proposed modifications. \ No newline at end of file +Everyone is welcome to contribute improvements and fixes to this project. There are no specific requirements, just create a pull request with proposed modifications and try to run [tests](https://github.com/paliarush/magento2-vagrant-for-developers-tests) on your local environment. \ No newline at end of file diff --git a/init_project.sh b/init_project.sh index 18813f60adc..0fce7ead9a3 100755 --- a/init_project.sh +++ b/init_project.sh @@ -5,6 +5,9 @@ magento_ce_dir="${vagrant_dir}/magento2ce" magento_ee_dir="${magento_ce_dir}/magento2ee" config_path="${vagrant_dir}/etc/config.yaml" host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") +use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") +repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce") +repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee") # Enable trace printing and exit on the first error set -ex @@ -65,11 +68,9 @@ if [[ ! -d ${magento_ce_dir} ]]; then git config --global diff.renamelimit 5000 fi # Check out CE repository - repository_url_ce=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce") git clone ${repository_url_ce} "${magento_ce_dir}" # Check out EE repository # By default EE repository is not specified and EE project is not checked out - repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee") if [[ -n "${repository_url_ee}" ]]; then git clone ${repository_url_ee} "${magento_ee_dir}" fi @@ -83,10 +84,15 @@ bash "${vagrant_dir}/scripts/host/composer.sh" install cd "${vagrant_dir}" vagrant up -if [[ -n "${repository_url_ee}" ]]; then - bash "${vagrant_dir}/m-switch-to-ee" -f +if [[ ${host_os} == "Windows" ]] || [[ ${use_nfs} == 0 ]]; then + # Automatic switch to EE during project initialization cannot be supported on Windows + bash "${vagrant_dir}/m-reinstall" else - bash "${vagrant_dir}/m-switch-to-ce" -f + if [[ -n "${repository_url_ee}" ]]; then + bash "${vagrant_dir}/m-switch-to-ee" -f + else + bash "${vagrant_dir}/m-switch-to-ce" -f + fi fi set +x @@ -104,8 +110,7 @@ echo " ${bold}[Important]${regular} Please use ${bold}${vagrant_dir}${regular} directory as PhpStorm project root, NOT ${bold}${magento_ce_dir}${regular}." -use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") -if [[ ${host_os} == "Windows" || ${use_nfs} == 0 ]]; then +if [[ ${host_os} == "Windows" ]] || [[ ${use_nfs} == 0 ]]; then echo " ${bold}[Optional]${regular} To verify that deployment configuration for ${bold}${magento_ce_dir}${regular} in PhpStorm is correct, diff --git a/m-switch-to-ce b/m-switch-to-ce index c6ceedee73a..b5680bd2c14 100755 --- a/m-switch-to-ce +++ b/m-switch-to-ce @@ -9,12 +9,6 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh") # Enable trace printing and exit on the first error set -ex -if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then - set +x - echo "EE codebase is not available" - exit 0 -fi - force_switch=0 while getopts 'f' flag; do case "${flag}" in @@ -23,6 +17,16 @@ while getopts 'f' flag; do esac done +if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then + set +x + echo "EE codebase is not available" + set -x + if [[ ${force_switch} -eq 1 ]]; then + bash "${vagrant_dir}/m-reinstall" + fi + exit 0 +fi + if [[ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]] && [[ ${force_switch} -eq 0 ]]; then set +x echo "Already switched to CE. Use 'm-switch-to-ce -f' to switch anyway." @@ -35,7 +39,7 @@ cd ${magento_ce_dir} git checkout composer.json git checkout composer.lock -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then # Prevent issues on Windows with incorrect symlinks to files if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json @@ -50,7 +54,7 @@ bash "${vagrant_dir}/m-clear-cache" bash -c "${vagrant_dir}/m-composer install" echo "Magento installation..." -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s fi diff --git a/m-switch-to-ee b/m-switch-to-ee index 7637030f4da..cc089435e8e 100755 --- a/m-switch-to-ee +++ b/m-switch-to-ee @@ -34,7 +34,7 @@ ${php_executable} -f ${magento_ee_dir}/dev/tools/build-ee.php -- --command=link cp ${magento_ee_dir}/composer.json ${magento_ce_dir}/composer.json cp ${magento_ee_dir}/composer.lock ${magento_ce_dir}/composer.lock -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then # Prevent issues on Windows with incorrect symlinks to files if [[ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]] && [[ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json @@ -51,7 +51,7 @@ bash "${vagrant_dir}/m-clear-cache" bash -c "${vagrant_dir}/m-composer install" echo "Magento installation..." -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then read -p "Wait while Magento2 code is uploaded in PhpStorm and press any key to continue..." -n1 -s fi diff --git a/scripts/guest/m-clear-cache b/scripts/guest/m-clear-cache index 3d67ee761ca..97f2224cc5a 100755 --- a/scripts/guest/m-clear-cache +++ b/scripts/guest/m-clear-cache @@ -2,14 +2,32 @@ echo "Clearing Magento cache..." -rm -f ${MAGENTO_ROOT}/app/etc/paths.php -#clear var -cd ${MAGENTO_ROOT} && mv var/.htaccess var_htaccess.back && rm -rf var/* var/.[^.]* && mv var_htaccess.back var/.htaccess -#clear pub/statics -cd ${MAGENTO_ROOT}/pub && mv static/.htaccess static_htaccess.back && rm -rf static && mkdir static && mv static_htaccess.back static/.htaccess -#clear integration tests tmp -cd ${MAGENTO_ROOT}/dev/tests/integration && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore -#clear unit tests tmp -cd ${MAGENTO_ROOT}/dev/tests/unit && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp && mv tmp_gitignore.back tmp/.gitignore +rm -f "${MAGENTO_ROOT}/app/etc/paths.php" +if [[ -d "${MAGENTO_ROOT}/var" ]]; then + #clear var + cd "${MAGENTO_ROOT}" && mv var/.htaccess var_htaccess.back && rm -rf var/* var/.[^.]* + if [[ -f var_htaccess.back ]]; then + mv var_htaccess.back var/.htaccess + fi +fi +if [[ -d "${MAGENTO_ROOT}/pub" ]]; then + #clear pub/statics + cd "${MAGENTO_ROOT}/pub" && mv static/.htaccess static_htaccess.back && rm -rf static && mkdir static + if [[ -f static_htaccess.back ]]; then + mv static_htaccess.back static/.htaccess + fi +fi +if [[ -d "${MAGENTO_ROOT}/dev" ]]; then + #clear integration tests tmp + cd "${MAGENTO_ROOT}/dev/tests/integration" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp + if [[ -f tmp_gitignore.back ]]; then + mv tmp_gitignore.back tmp/.gitignore + fi + #clear unit tests tmp + cd "${MAGENTO_ROOT}/dev/tests/unit" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp && mkdir tmp + if [[ -f tmp_gitignore.back ]]; then + mv tmp_gitignore.back tmp/.gitignore + fi +fi echo "Magento cache cleared." diff --git a/scripts/guest/m-reinstall b/scripts/guest/m-reinstall index 1f94cbfe681..c023b9f9c01 100755 --- a/scripts/guest/m-reinstall +++ b/scripts/guest/m-reinstall @@ -6,6 +6,8 @@ set -ex get_config_value="/vagrant/scripts/get_config_value.sh" magento_host_name=$(bash ${get_config_value} "magento_host_name") vagrant_dir="/vagrant" +use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") +is_windows_host=${IS_WINDOWS_HOST} declare -A setupOptions setupOptions[admin_frontname]=$(bash ${get_config_value} "magento_admin_frontname") @@ -27,6 +29,10 @@ setupOptions[amqp_user]='guest' setupOptions[amqp_password]='guest' setupOptions[amqp_virtualhost]='/' +if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then + sudo chown -R vagrant:vagrant ${MAGENTO_ROOT} +fi + cd ${MAGENTO_ROOT} # Clear cache @@ -72,7 +78,7 @@ if [[ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ]]; then --amqp-password=${setupOptions[amqp_password]}" fi -chmod +x bin/magento +sudo chmod +x bin/magento php ${install_cmd} # Comment out the line above and uncomment the one below to debug Magento Setup script # php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd} @@ -82,10 +88,8 @@ echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run & * * * * * php ${MAGENTO_ROOT}/update/cron.php & * * * * * php ${MAGENTO_ROOT}/bin/magento setup:cron:run &" | crontab -u vagrant - -use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") -is_windows_host=${IS_WINDOWS_HOST} -if [[ ${is_windows_host} == 1 || ${use_nfs} == 0 ]]; then - chown -R vagrant:vagrant ${MAGENTO_ROOT} +if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then + sudo chown -R vagrant:vagrant ${MAGENTO_ROOT} fi # Generate XSD references for PHP Storm diff --git a/scripts/host/configure_php_storm.sh b/scripts/host/configure_php_storm.sh index 3c1c7bf0684..54243adb827 100755 --- a/scripts/host/configure_php_storm.sh +++ b/scripts/host/configure_php_storm.sh @@ -14,7 +14,7 @@ cp -R "${vagrant_dir}/scripts/host/php-storm-configs/." "${vagrant_dir}/.idea/" enabled_virtual_host_config="/etc/apache2/sites-available/magento2.conf" host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh") -if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then +if [[ ${host_os} == "Windows" ]] || [[ $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then sed -i.back "s||/var/www/magento2ce|g" "${vagrant_dir}/.idea/deployment.xml" sed -i.back 's|| autoUpload="Always" autoUploadExternalChanges="true"|g' "${vagrant_dir}/.idea/deployment.xml" sed -i.back 's||