From 92a22ada8e97e2aa52836c28b1ca4b99614ec5cf Mon Sep 17 00:00:00 2001 From: tomjn Date: Fri, 4 Dec 2020 19:03:20 +0000 Subject: [PATCH 01/47] if the VM has yet to be created, we aren't on windows, the process user is root and we're using virtualbox, abort abort --- Vagrantfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index 6cf33f5da..e69174fa2 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,6 +5,7 @@ Vagrant.require_version '>= 2.2.4' require 'yaml' require 'fileutils' +require 'pathname' def virtualbox_path @vboxmanage_path = nil @@ -375,6 +376,17 @@ Vagrant.configure('2') do |config| # Configurations from 1.0.x can be placed in Vagrant 1.1.x specs like the following. config.vm.provider :virtualbox do |v| + + unless Vagrant::Util::Platform.windows? + if Process.uid == 0 + machine_id_file=Pathname.new(".vagrant/machines/default/virtualbox/id") + unless machine_id_file.exist?() + puts " ! VVV has detected that the VM has not been created yet, and is running as root/sudo." + puts " ! Do not use sudo with VVV, do not run VVV as a root user. Aborting." + abort( "Aborting Vagrant command to prevent a critical mistake, do not use sudo/root with VVV." ) + end + end + end # Move the ubuntu-bionic-18.04-cloudimg-console.log file to log directory. v.customize ['modifyvm', :id, '--uartmode1', 'file', File.join(vagrant_dir, 'log/ubuntu-bionic-18.04-cloudimg-console.log')] From 71bd4608402addcb9a2f84703295a7d4ad59cceb Mon Sep 17 00:00:00 2001 From: tomjn Date: Fri, 4 Dec 2020 19:04:48 +0000 Subject: [PATCH 02/47] a more prominent message --- Vagrantfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Vagrantfile b/Vagrantfile index e69174fa2..4482214a0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -381,6 +381,7 @@ Vagrant.configure('2') do |config| if Process.uid == 0 machine_id_file=Pathname.new(".vagrant/machines/default/virtualbox/id") unless machine_id_file.exist?() + puts "#{red} ⚠ DANGER VAGRANT IS RUNNING AS ROOT/SUDO, DO NOT USE SUDO ⚠#{creset}" puts " ! VVV has detected that the VM has not been created yet, and is running as root/sudo." puts " ! Do not use sudo with VVV, do not run VVV as a root user. Aborting." abort( "Aborting Vagrant command to prevent a critical mistake, do not use sudo/root with VVV." ) From 455885047b6893031524b8ca49009c887ce693b4 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Wed, 21 Jul 2021 16:41:18 +0200 Subject: [PATCH 03/47] feat(nginx): fallback setting --- .../core/nginx/config/sites/fallback.conf | 23 +++++++++++++++++++ provision/provision-site.sh | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 provision/core/nginx/config/sites/fallback.conf diff --git a/provision/core/nginx/config/sites/fallback.conf b/provision/core/nginx/config/sites/fallback.conf new file mode 100644 index 000000000..fb8becd8e --- /dev/null +++ b/provision/core/nginx/config/sites/fallback.conf @@ -0,0 +1,23 @@ +server { + listen 80; + listen 443 ssl http2; + server_name {vvv_hosts}; + root "{vvv_path_to_site}{vvv_public_dir}"; + + # Nginx logs + error_log "{vvv_path_to_site}/log/nginx-error.log"; + access_log "{vvv_path_to_site}/log/nginx-access.log"; + + # Enable server push if SSL/HTTP2 is being used for link preload headers + http2_push_preload on; + + {vvv_tls_cert} + {vvv_tls_key} + + # Nginx rules for WordPress, rewrite rules, permalinks, etc + include /etc/nginx/nginx-wp-common.conf; + + location ~* \.(css|eot|gif|ico|jpeg|jpg|js|png|svg|tiff|tiff|ttf|webp|woff|woff2)$ { + expires 100d; + } +} diff --git a/provision/provision-site.sh b/provision/provision-site.sh index ef539d14f..bab56ff10 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -84,6 +84,10 @@ function get_primary_host() { function vvv_provision_site_nginx_config() { local SITE_NAME=$1 local SITE_NGINX_FILE=$2 + if [ ! -f "$SITE_NGINX_FILE" ]; then + vvv_warn " * VVV didn't found any Nginx config file, it will use a fallback config file" + cp -f "/srv/provision/core/nginx/config/sites/fallback.conf" $SITE_NGINX_FILE + fi local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} From d76765c123a8b2497c54038f88c6fc2e5370da1f Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Wed, 21 Jul 2021 16:46:41 +0200 Subject: [PATCH 04/47] feat(nginx): fallback setting --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index bab56ff10..ebd04527d 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -86,7 +86,7 @@ function vvv_provision_site_nginx_config() { local SITE_NGINX_FILE=$2 if [ ! -f "$SITE_NGINX_FILE" ]; then vvv_warn " * VVV didn't found any Nginx config file, it will use a fallback config file" - cp -f "/srv/provision/core/nginx/config/sites/fallback.conf" $SITE_NGINX_FILE + cp -f "/srv/provision/core/nginx/config/sites/fallback.conf" "$SITE_NGINX_FILE" fi local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} From b92a044d0736ce2979af1f084adeb8ba538e67b3 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 26 Jul 2022 12:00:31 +0200 Subject: [PATCH 05/47] feat(php): recommit changes --- CHANGELOG.md | 3 +- config/default-config.yml | 1 + config/homebin/vvv_restore_php_default | 17 ++-- provision/provision-site.sh | 103 ++++++++++++++----------- provision/provisioners.sh | 1 + 5 files changed, 72 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aee178f6..860af1baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ permalink: /docs/en-US/changelog/ * Improved provisioning output * VVV will now attempt to test Nginx configs on installation and recover ( #2604 ) * Switched to new launchpad PPA domains with HTTPS ( #2586 ) -* Improved the verboseness of the DB import scripts ( #2621 ) +* Improved the verboseness of the DB import scripts ( #2621 ) +* PHP version parameter for provisioner and Nginx ( #2583 ) ### Bug Fixes diff --git a/config/default-config.yml b/config/default-config.yml index 644faf988..f8f0f3505 100644 --- a/config/default-config.yml +++ b/config/default-config.yml @@ -36,6 +36,7 @@ sites: skip_provisioning: false description: "A standard WP install, useful for building plugins, testing things, etc" repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git + php: 7.4 # change the PHP version to use for the provision and nginx custom: # locale: it_IT delete_default_plugins: true diff --git a/config/homebin/vvv_restore_php_default b/config/homebin/vvv_restore_php_default index 2e1506e29..ae88fc1e0 100755 --- a/config/homebin/vvv_restore_php_default +++ b/config/homebin/vvv_restore_php_default @@ -1,10 +1,13 @@ #!/bin/bash DEFAULTPHP="7.4" -echo " * Restoring the default PHP CLI version ( ${DEFAULTPHP} )" -update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" -update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" -update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" -update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" -update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" -echo " * Restoration complete" +php_version=$(readlink -f /usr/bin/php) +if [[ $php_version != *"${DEFAULTPHP}"* ]]; then + echo " * Restoring the default PHP CLI version ( ${DEFAULTPHP} )" + update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" + update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" + update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" + update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" + update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" + echo " * Restoration complete" +fi diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 778bd0d03..19d4ce95c 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -24,12 +24,43 @@ VVV_PATH_TO_SITE=${VM_DIR} # used in site templates VVV_SITE_NAME=${SITE} VVV_HOSTS="" +local DEFAULTPHP=$(vvv_get_site_config_value 'php' "${VVV_BASE_PHPVERSION}") +echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" +update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" +update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" +update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" +update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" +update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" + SUCCESS=1 VVV_CONFIG=/vagrant/config.yml . "/srv/provision/provisioners.sh" +# @description Retrieves a config value for the given site as specified in `config.yml` +# +# @arg $1 string the config value to fetch +# @arg $2 string the default value +function vvv_get_site_config_value() { + local value=$(shyaml -q get-value "sites.${SITE_ESCAPED}.${1}" "${2}" < ${VVV_CONFIG}) + echo "${value}" +} + +# @description Reset the PHP global version to the default +function vvv_set_php_cli_version() { + php_version=$(readlink -f /usr/bin/php) + if [[ $php_version != *"${VVV_BASE_PHPVERSION}"* ]]; then + DEFAULTPHP=$(vvv_get_site_config_value 'php' "${VVV_BASE_PHPVERSION}") + echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" + update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" + update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" + update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" + update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" + update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" + fi +} + # @description Takes 2 values, a key to fetch a value for, and an optional default value # # @example @@ -84,53 +115,45 @@ function get_primary_host() { function vvv_provision_site_nginx_config() { local SITE_NAME=$1 local SITE_NGINX_FILE=$2 + local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} + local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} + local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} + local DEST_NGINX_FILE="vvv-auto-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-32).conf" VVV_HOSTS=$(get_hosts) - local TMPFILE=$(mktemp /tmp/vvv-site-XXXXX) - cat "${SITE_NGINX_FILE}" >> "${TMPFILE}" vvv_info " * VVV is adding an Nginx config from ${SITE_NGINX_FILE}" # We allow the replacement of the {vvv_path_to_folder} token with # whatever you want, allowing flexible placement of the site folder # while still having an Nginx config which works. - local DIR="$(dirname "${SITE_NGINX_FILE}")" - sed "s#{vvv_path_to_folder}#${DIR}#" "${SITE_NGINX_FILE}" > "${TMPFILE}" - sed -i "s#{vvv_path_to_site}#${VM_DIR}#" "${TMPFILE}" - sed -i "s#{vvv_site_name}#${SITE_NAME}#" "${TMPFILE}" - sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "${TMPFILE}" + local DIR="$(dirname "$SITE_NGINX_FILE")" + sed "s#{vvv_path_to_folder}#${DIR}#" "$SITE_NGINX_FILE" > "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_path_to_site}#${VM_DIR}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_site_name}#${SITE_NAME}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" if [ 'php' != "${NGINX_UPSTREAM}" ] && [ ! -f "/etc/nginx/upstreams/${NGINX_UPSTREAM}.conf" ]; then vvv_error " * Upstream value '${NGINX_UPSTREAM}' doesn't match a valid upstream. Defaulting to 'php'.${CRESET}" NGINX_UPSTREAM='php' + DEFAULTPHP=$(vvv_get_site_config_value 'php' "") + if [ '' != "${DEFAULTPHP}" ]; then + NGINX_UPSTREAM=$DEFAULTPHP + fi fi - sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" + sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" if [ -f "/srv/certificates/${SITE_NAME}/dev.crt" ]; then - sed -i "s#{vvv_tls_cert}#ssl_certificate \"/srv/certificates/${SITE_NAME}/dev.crt\";#" "${TMPFILE}" - sed -i "s#{vvv_tls_key}#ssl_certificate_key \"/srv/certificates/${SITE_NAME}/dev.key\";#" "${TMPFILE}" + sed -i "s#{vvv_tls_cert}#ssl_certificate \"/srv/certificates/${SITE_NAME}/dev.crt\";#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_tls_key}#ssl_certificate_key \"/srv/certificates/${SITE_NAME}/dev.key\";#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" else - sed -i "s#{vvv_tls_cert}#\# TLS cert not included as the certificate file is not present#" "${TMPFILE}" - sed -i "s#{vvv_tls_key}#\# TLS key not included as the certificate file is not present#" "${TMPFILE}" + sed -i "s#{vvv_tls_cert}#\# TLS cert not included as the certificate file is not present#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_tls_key}#\# TLS key not included as the certificate file is not present#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" fi # Resolve relative paths since not supported in Nginx root. - while grep -sqE '/[^/][^/]*/\.\.' "${TMPFILE}"; do - sed -i 's#/[^/][^/]*/\.\.##g' "${TMPFILE}" + while grep -sqE '/[^/][^/]*/\.\.' "/etc/nginx/custom-sites/${DEST_NGINX_FILE}"; do + sed -i 's#/[^/][^/]*/\.\.##g' "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" done - - # "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" - local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} - local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} - local DEST_NGINX_FILE=${DEST_NGINX_FILE//-provision/} # remove the provision folder name - local DEST_NGINX_FILE=${DEST_NGINX_FILE//-.vvv/} # remove the .vvv folder name - local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} - local DEST_NGINX_FILE="vvv-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-8).conf" - - if ! vvv_maybe_install_nginx_config "${TMPFILE}" "${DEST_NGINX_FILE}" "sites"; then - vvv_warn " ! This sites nginx config had problems, it may not load. Look at the above errors to diagnose the problem" - vvv_info " ! VVV will now continue with provisioning so that other sites have an opportunity to run" - fi - rm -f "${TMPFILE}" } # @description add hosts from a file to VVVs hosts file (the guest, not the host machine) @@ -205,7 +228,7 @@ function vvv_provision_site_repo() { echo " * Any local changes not present on the server will be discarded in favor of the remote branch" cd "${VM_DIR}" echo " * Checking that remote origin is ${REPO}" - CURRENTORIGIN=$(noroot git remote get-url origin) + CURRENTORIGIN=$(git remote get-url origin) if [[ "${CURRENTORIGIN}" != "${REPO}" ]]; then vvv_error " ! The site config said to use ${REPO}" vvv_error " ! But the origin remote is actually ${CURRENTORIGIN}" @@ -331,14 +354,6 @@ function vvv_provision_site_nginx() { fi } -# @description Retrieves a config value for the given site as specified in `config.yml` -# -# @arg $1 string the config value to fetch -# @arg $2 string the default value -function vvv_get_site_config_value() { - local value=$(shyaml -q get-value "sites.${SITE_ESCAPED}.${1}" "${2}" < ${VVV_CONFIG}) - echo "${value}" -} # @description Clones a git repository into a sites sub-folder # @@ -484,20 +499,13 @@ function vvv_custom_folders() { } # ------------------------------- +vvv_set_php_cli_version() if [[ true == "${SKIP_PROVISIONING}" ]]; then vvv_warn " * Skipping provisioning of ${SITE}" exit 0 fi -# Ensure npm is available -if ! command -v nvm &> /dev/null; then - if [ -f /home/vagrant/.nvm/nvm.sh ]; then - source /home/vagrant/.nvm/nvm.sh - fi -fi -nvm use default - vvv_provision_site_repo if [[ ! -d "${VM_DIR}" ]]; then @@ -516,9 +524,14 @@ vvv_provision_site_script vvv_custom_folders vvv_provision_site_nginx +vvv_info " * Reloading Nginx" +service nginx reload + if [ "${SUCCESS}" -ne "0" ]; then vvv_error " ! ${SITE} provisioning had some issues, check the log files as the site may not function correctly." exit 1 fi +vvv_restore_php_default + provisioner_success diff --git a/provision/provisioners.sh b/provision/provisioners.sh index 4a7f1f7aa..657f8762d 100755 --- a/provision/provisioners.sh +++ b/provision/provisioners.sh @@ -37,6 +37,7 @@ function provisioner_end() { else vvv_error " ! The '${VVV_PROVISIONER_RUNNING}' provisioner ran into problems, the full log is available at '${VVV_CURRENT_LOG_FILE}'. It completed in ${elapsed} seconds." fi + /srv/config/homebin/vvv_restore_php_default trap - EXIT } From fdd24aaba0c3e54cb9968f02fa20fa39b0c6a155 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 26 Jul 2022 12:03:44 +0200 Subject: [PATCH 06/47] feat(php): recommit changes --- provision/provision-site.sh | 57 ++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 19d4ce95c..58a7e86e8 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -115,22 +115,20 @@ function get_primary_host() { function vvv_provision_site_nginx_config() { local SITE_NAME=$1 local SITE_NGINX_FILE=$2 - local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} - local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} - local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} - local DEST_NGINX_FILE="vvv-auto-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-32).conf" VVV_HOSTS=$(get_hosts) + local TMPFILE=$(mktemp /tmp/vvv-site-XXXXX) + cat "${SITE_NGINX_FILE}" >> "${TMPFILE}" vvv_info " * VVV is adding an Nginx config from ${SITE_NGINX_FILE}" # We allow the replacement of the {vvv_path_to_folder} token with # whatever you want, allowing flexible placement of the site folder # while still having an Nginx config which works. - local DIR="$(dirname "$SITE_NGINX_FILE")" - sed "s#{vvv_path_to_folder}#${DIR}#" "$SITE_NGINX_FILE" > "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" - sed -i "s#{vvv_path_to_site}#${VM_DIR}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" - sed -i "s#{vvv_site_name}#${SITE_NAME}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" - sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + local DIR="$(dirname "${SITE_NGINX_FILE}")" + sed "s#{vvv_path_to_folder}#${DIR}#" "${SITE_NGINX_FILE}" > "${TMPFILE}" + sed -i "s#{vvv_path_to_site}#${VM_DIR}#" "${TMPFILE}" + sed -i "s#{vvv_site_name}#${SITE_NAME}#" "${TMPFILE}" + sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "${TMPFILE}" if [ 'php' != "${NGINX_UPSTREAM}" ] && [ ! -f "/etc/nginx/upstreams/${NGINX_UPSTREAM}.conf" ]; then vvv_error " * Upstream value '${NGINX_UPSTREAM}' doesn't match a valid upstream. Defaulting to 'php'.${CRESET}" @@ -140,20 +138,34 @@ function vvv_provision_site_nginx_config() { NGINX_UPSTREAM=$DEFAULTPHP fi fi - sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" if [ -f "/srv/certificates/${SITE_NAME}/dev.crt" ]; then - sed -i "s#{vvv_tls_cert}#ssl_certificate \"/srv/certificates/${SITE_NAME}/dev.crt\";#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" - sed -i "s#{vvv_tls_key}#ssl_certificate_key \"/srv/certificates/${SITE_NAME}/dev.key\";#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_tls_cert}#ssl_certificate \"/srv/certificates/${SITE_NAME}/dev.crt\";#" "${TMPFILE}" + sed -i "s#{vvv_tls_key}#ssl_certificate_key \"/srv/certificates/${SITE_NAME}/dev.key\";#" "${TMPFILE}" else - sed -i "s#{vvv_tls_cert}#\# TLS cert not included as the certificate file is not present#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" - sed -i "s#{vvv_tls_key}#\# TLS key not included as the certificate file is not present#" "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + sed -i "s#{vvv_tls_cert}#\# TLS cert not included as the certificate file is not present#" "${TMPFILE}" + sed -i "s#{vvv_tls_key}#\# TLS key not included as the certificate file is not present#" "${TMPFILE}" fi # Resolve relative paths since not supported in Nginx root. - while grep -sqE '/[^/][^/]*/\.\.' "/etc/nginx/custom-sites/${DEST_NGINX_FILE}"; do - sed -i 's#/[^/][^/]*/\.\.##g' "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + while grep -sqE '/[^/][^/]*/\.\.' "${TMPFILE}"; do + sed -i 's#/[^/][^/]*/\.\.##g' "${TMPFILE}" done + + # "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" + local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} + local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} + local DEST_NGINX_FILE=${DEST_NGINX_FILE//-provision/} # remove the provision folder name + local DEST_NGINX_FILE=${DEST_NGINX_FILE//-.vvv/} # remove the .vvv folder name + local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} + local DEST_NGINX_FILE="vvv-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-8).conf" + + if ! vvv_maybe_install_nginx_config "${TMPFILE}" "${DEST_NGINX_FILE}" "sites"; then + vvv_warn " ! This sites nginx config had problems, it may not load. Look at the above errors to diagnose the problem" + vvv_info " ! VVV will now continue with provisioning so that other sites have an opportunity to run" + fi + rm -f "${TMPFILE}" } # @description add hosts from a file to VVVs hosts file (the guest, not the host machine) @@ -228,7 +240,7 @@ function vvv_provision_site_repo() { echo " * Any local changes not present on the server will be discarded in favor of the remote branch" cd "${VM_DIR}" echo " * Checking that remote origin is ${REPO}" - CURRENTORIGIN=$(git remote get-url origin) + CURRENTORIGIN=$(noroot git remote get-url origin) if [[ "${CURRENTORIGIN}" != "${REPO}" ]]; then vvv_error " ! The site config said to use ${REPO}" vvv_error " ! But the origin remote is actually ${CURRENTORIGIN}" @@ -506,6 +518,14 @@ if [[ true == "${SKIP_PROVISIONING}" ]]; then exit 0 fi +# Ensure npm is available +if ! command -v nvm &> /dev/null; then + if [ -f /home/vagrant/.nvm/nvm.sh ]; then + source /home/vagrant/.nvm/nvm.sh + fi +fi +nvm use default + vvv_provision_site_repo if [[ ! -d "${VM_DIR}" ]]; then @@ -524,9 +544,6 @@ vvv_provision_site_script vvv_custom_folders vvv_provision_site_nginx -vvv_info " * Reloading Nginx" -service nginx reload - if [ "${SUCCESS}" -ne "0" ]; then vvv_error " ! ${SITE} provisioning had some issues, check the log files as the site may not function correctly." exit 1 From 3b9c7db9182b11ce3806fc9cb3016af69678dc6d Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 26 Jul 2022 17:29:45 +0200 Subject: [PATCH 07/47] fix(php): strip --- provision/provision-site.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 58a7e86e8..7bf0d1c8e 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -130,12 +130,14 @@ function vvv_provision_site_nginx_config() { sed -i "s#{vvv_site_name}#${SITE_NAME}#" "${TMPFILE}" sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "${TMPFILE}" + # if nginx upstream is not 'php' then it has been changed in config.yml if [ 'php' != "${NGINX_UPSTREAM}" ] && [ ! -f "/etc/nginx/upstreams/${NGINX_UPSTREAM}.conf" ]; then vvv_error " * Upstream value '${NGINX_UPSTREAM}' doesn't match a valid upstream. Defaulting to 'php'.${CRESET}" NGINX_UPSTREAM='php' - DEFAULTPHP=$(vvv_get_site_config_value 'php' "") + DEFAULTPHP=$(vvv_get_site_config_value 'php' "" | tr --delete .) + # if php: is configured, set the upstream to match if [ '' != "${DEFAULTPHP}" ]; then - NGINX_UPSTREAM=$DEFAULTPHP + NGINX_UPSTREAM="php${DEFAULTPHP}" fi fi sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" From 9baee79b1788477641290e5e638cb21006a08905 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 26 Jul 2022 17:42:29 +0200 Subject: [PATCH 08/47] fix(php): fix variable --- provision/provision-site.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 7bf0d1c8e..a1c5b1b63 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -24,16 +24,6 @@ VVV_PATH_TO_SITE=${VM_DIR} # used in site templates VVV_SITE_NAME=${SITE} VVV_HOSTS="" -local DEFAULTPHP=$(vvv_get_site_config_value 'php' "${VVV_BASE_PHPVERSION}") -echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" -update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" -update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" -update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" -update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" -update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" - -SUCCESS=1 - VVV_CONFIG=/vagrant/config.yml . "/srv/provision/provisioners.sh" @@ -47,6 +37,16 @@ function vvv_get_site_config_value() { echo "${value}" } +local DEFAULTPHP=$(vvv_get_site_config_value 'php' "${VVV_BASE_PHPVERSION}") +echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" +update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" +update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" +update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" +update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" +update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" + +SUCCESS=1 + # @description Reset the PHP global version to the default function vvv_set_php_cli_version() { php_version=$(readlink -f /usr/bin/php) From ed8e00d91ce3c4b1a88777d5250a3e431ff0c177 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 26 Jul 2022 19:27:02 +0200 Subject: [PATCH 09/47] fix(php): fix variable --- provision/provision-site.sh | 43 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index a1c5b1b63..eadf6296b 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -23,6 +23,7 @@ NGINX_UPSTREAM=$6 VVV_PATH_TO_SITE=${VM_DIR} # used in site templates VVV_SITE_NAME=${SITE} VVV_HOSTS="" +SUCCESS=1 VVV_CONFIG=/vagrant/config.yml @@ -37,27 +38,20 @@ function vvv_get_site_config_value() { echo "${value}" } -local DEFAULTPHP=$(vvv_get_site_config_value 'php' "${VVV_BASE_PHPVERSION}") -echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" -update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" -update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" -update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" -update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" -update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" - -SUCCESS=1 - # @description Reset the PHP global version to the default +# +# @internal +# @noargs function vvv_set_php_cli_version() { php_version=$(readlink -f /usr/bin/php) - if [[ $php_version != *"${VVV_BASE_PHPVERSION}"* ]]; then - DEFAULTPHP=$(vvv_get_site_config_value 'php' "${VVV_BASE_PHPVERSION}") + DEFAULTPHP=$(vvv_get_site_config_value 'php' "${DEFAULTPHP}") + if [[ $php_version != *"${DEFAULTPHP}"* ]]; then echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" - update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" - update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" - update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" - update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" - update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" + update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" &> /dev/null + update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" &> /dev/null + update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" &> /dev/null + update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" &> /dev/null + update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" &> /dev/null fi } @@ -134,11 +128,12 @@ function vvv_provision_site_nginx_config() { if [ 'php' != "${NGINX_UPSTREAM}" ] && [ ! -f "/etc/nginx/upstreams/${NGINX_UPSTREAM}.conf" ]; then vvv_error " * Upstream value '${NGINX_UPSTREAM}' doesn't match a valid upstream. Defaulting to 'php'.${CRESET}" NGINX_UPSTREAM='php' - DEFAULTPHP=$(vvv_get_site_config_value 'php' "" | tr --delete .) - # if php: is configured, set the upstream to match - if [ '' != "${DEFAULTPHP}" ]; then - NGINX_UPSTREAM="php${DEFAULTPHP}" - fi + fi + + # if php: is configured, set the upstream to match + if [ "${DEFAULTPHP}" != "${VVV_DEFAULTPHP}" ]; then + NGINX_UPSTREAM="php${DEFAULTPHP}" + NGINX_UPSTREAM=$(echo $NGINX_UPSTREAM | tr --delete .) fi sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" @@ -513,7 +508,9 @@ function vvv_custom_folders() { } # ------------------------------- -vvv_set_php_cli_version() +source /srv/config/homebin/vvv_restore_php_default +VVV_DEFAULTPHP=$DEFAULT_PHP +vvv_set_php_cli_version if [[ true == "${SKIP_PROVISIONING}" ]]; then vvv_warn " * Skipping provisioning of ${SITE}" From 38727c209dd121b2ae6f1af86a943e4d236e1281 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Aug 2022 12:55:51 +0200 Subject: [PATCH 10/47] Update provision/provision-site.sh Co-authored-by: Tom J Nowell --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index eadf6296b..b32061f00 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -38,7 +38,7 @@ function vvv_get_site_config_value() { echo "${value}" } -# @description Reset the PHP global version to the default +# @description sets a sites PHP version as the global version, or to the VVV default if none is specified # # @internal # @noargs From 2f7ce40247a17c4c47cdb9eb453865ea95f97ce7 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Aug 2022 12:55:58 +0200 Subject: [PATCH 11/47] Update provision/provision-site.sh Co-authored-by: Tom J Nowell --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index b32061f00..ddaa3a783 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -124,7 +124,7 @@ function vvv_provision_site_nginx_config() { sed -i "s#{vvv_site_name}#${SITE_NAME}#" "${TMPFILE}" sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "${TMPFILE}" - # if nginx upstream is not 'php' then it has been changed in config.yml + # check if the nginx upstream value has been set and is valid if [ 'php' != "${NGINX_UPSTREAM}" ] && [ ! -f "/etc/nginx/upstreams/${NGINX_UPSTREAM}.conf" ]; then vvv_error " * Upstream value '${NGINX_UPSTREAM}' doesn't match a valid upstream. Defaulting to 'php'.${CRESET}" NGINX_UPSTREAM='php' From c72bd4bc11aac14aeb76e29deb8f9e448f3e51ae Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Aug 2022 13:07:17 +0200 Subject: [PATCH 12/47] fix(provision): switched lines --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index ddaa3a783..5e8a45cbd 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -132,8 +132,8 @@ function vvv_provision_site_nginx_config() { # if php: is configured, set the upstream to match if [ "${DEFAULTPHP}" != "${VVV_DEFAULTPHP}" ]; then - NGINX_UPSTREAM="php${DEFAULTPHP}" NGINX_UPSTREAM=$(echo $NGINX_UPSTREAM | tr --delete .) + NGINX_UPSTREAM="php${DEFAULTPHP}" fi sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" From 87e7e9795485fabfc1d8d26898e8ba559252aeed Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Aug 2022 14:25:11 +0200 Subject: [PATCH 13/47] feat(php): version validation --- provision/provision-site.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 5e8a45cbd..7483d57da 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -46,12 +46,17 @@ function vvv_set_php_cli_version() { php_version=$(readlink -f /usr/bin/php) DEFAULTPHP=$(vvv_get_site_config_value 'php' "${DEFAULTPHP}") if [[ $php_version != *"${DEFAULTPHP}"* ]]; then - echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" - update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" &> /dev/null - update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" &> /dev/null - update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" &> /dev/null - update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" &> /dev/null - update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" &> /dev/null + length=$(echo "$DEFAULTPHP" | wc -c) + if [[ $length != '3' ]]; then + vvv_warning " ! Warning: PHP version defined is using a wrong format" + else + echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" + update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" &> /dev/null + update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" &> /dev/null + update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" &> /dev/null + update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" &> /dev/null + update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" &> /dev/null + fi fi } @@ -132,7 +137,7 @@ function vvv_provision_site_nginx_config() { # if php: is configured, set the upstream to match if [ "${DEFAULTPHP}" != "${VVV_DEFAULTPHP}" ]; then - NGINX_UPSTREAM=$(echo $NGINX_UPSTREAM | tr --delete .) + NGINX_UPSTREAM=$(echo "$NGINX_UPSTREAM" | tr --delete .) NGINX_UPSTREAM="php${DEFAULTPHP}" fi sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" From 3bc2786717cb76c064833e1ef020a7cd4f6d3e8e Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 23 Aug 2022 10:45:15 +0200 Subject: [PATCH 14/47] fix(php): use right php version --- provision/provision-site.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 7483d57da..ffef7eece 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -129,17 +129,18 @@ function vvv_provision_site_nginx_config() { sed -i "s#{vvv_site_name}#${SITE_NAME}#" "${TMPFILE}" sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "${TMPFILE}" + # if php: is configured, set the upstream to match + if [ "${DEFAULTPHP}" != "${VVV_DEFAULTPHP}" ]; then + NGINX_UPSTREAM="php${DEFAULTPHP}" + NGINX_UPSTREAM=$(echo "$NGINX_UPSTREAM" | tr --delete .) + fi + # check if the nginx upstream value has been set and is valid if [ 'php' != "${NGINX_UPSTREAM}" ] && [ ! -f "/etc/nginx/upstreams/${NGINX_UPSTREAM}.conf" ]; then vvv_error " * Upstream value '${NGINX_UPSTREAM}' doesn't match a valid upstream. Defaulting to 'php'.${CRESET}" NGINX_UPSTREAM='php' fi - # if php: is configured, set the upstream to match - if [ "${DEFAULTPHP}" != "${VVV_DEFAULTPHP}" ]; then - NGINX_UPSTREAM=$(echo "$NGINX_UPSTREAM" | tr --delete .) - NGINX_UPSTREAM="php${DEFAULTPHP}" - fi sed -i "s#{upstream}#${NGINX_UPSTREAM}#" "${TMPFILE}" if [ -f "/srv/certificates/${SITE_NAME}/dev.crt" ]; then From 125c46e3891a669c7f320c1f32dfb38593e78e5b Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Wed, 7 Sep 2022 14:47:19 +0100 Subject: [PATCH 15/47] fix a misnamed function call when provisioning a site --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index ffef7eece..e500dc3d5 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -48,7 +48,7 @@ function vvv_set_php_cli_version() { if [[ $php_version != *"${DEFAULTPHP}"* ]]; then length=$(echo "$DEFAULTPHP" | wc -c) if [[ $length != '3' ]]; then - vvv_warning " ! Warning: PHP version defined is using a wrong format" + vvv_warn " ! Warning: PHP version defined is using a wrong format" else echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" &> /dev/null From 87372c42708ee50119838d6990789dc41fb95b3f Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Wed, 7 Sep 2022 14:53:56 +0100 Subject: [PATCH 16/47] refactor the PHP version validation check to also print out what it thought the version was --- provision/provision-site.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index e500dc3d5..9dd1e986c 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -47,8 +47,8 @@ function vvv_set_php_cli_version() { DEFAULTPHP=$(vvv_get_site_config_value 'php' "${DEFAULTPHP}") if [[ $php_version != *"${DEFAULTPHP}"* ]]; then length=$(echo "$DEFAULTPHP" | wc -c) - if [[ $length != '3' ]]; then - vvv_warn " ! Warning: PHP version defined is using a wrong format" + if [[ $length > '3' ]]; then + vvv_warn " ! Warning: PHP version defined is using a wrong format: '${DEFAULTPHP}' with length '${length}'" else echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" &> /dev/null From 784a4cecc6b8964296dea64682ba43178673b68a Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sat, 10 Sep 2022 11:58:42 +0100 Subject: [PATCH 17/47] start the 3.11 cycle --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fafc96405..2cd09a49b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ permalink: /docs/en-US/changelog/ # Changelog +## 3.11.0 ( WIP ) + +### Enhancements + +* .... + +### Bug Fixes + +* .... + ## 3.10.1 ( 2022 September 10th ) ### Enhancements From 74fd241cb976463368723f4e3753199289ddf501 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sat, 10 Sep 2022 12:35:01 +0100 Subject: [PATCH 18/47] bump version number to 3.11 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index a8819280c..902b2c90c 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.10.1 \ No newline at end of file +3.11 \ No newline at end of file From 7116807974dea424872edc7f459f04a388540c8e Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 11 Sep 2022 17:25:51 +0100 Subject: [PATCH 19/47] split virtualbox box into only virtualbox --- Vagrantfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 3b7fbf1a2..a4b0e255b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -398,13 +398,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # This is disabled, we had several contributors who ran into issues. # See: https://github.com/Varying-Vagrant-Vagrants/VVV/issues/1551 config.ssh.insert_key = false - - # Default Ubuntu Box - # - # This box is provided by Bento boxes via vagrantcloud.com and is a nicely sized - # box containing the Ubuntu 20.04 Focal 64 bit release. Once this box is downloaded - # to your host computer, it is cached for future use under the specified box name. - config.vm.box = 'bento/ubuntu-20.04' config.vm.box_check_update = false # The Parallels Provider uses a different naming scheme. @@ -432,6 +425,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Virtualbox. config.vm.provider :virtualbox do |_v, override| + # Default Ubuntu Box + # + # This box is provided by Bento boxes via vagrantcloud.com and is a nicely sized + # box containing the Ubuntu 20.04 Focal 64 bit release. Once this box is downloaded + # to your host computer, it is cached for future use under the specified box name. override.vm.box = 'bento/ubuntu-20.04' # If we're at a contributor day, switch the base box to the prebuilt one From 173128f778a99ab93d6d6e550852fc6e47d27a99 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 11 Sep 2022 17:29:43 +0100 Subject: [PATCH 20/47] Better switch php debug mod compatibility with docker images --- config/homebin/switch_php_debugmod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/homebin/switch_php_debugmod b/config/homebin/switch_php_debugmod index ccd9233f9..0999a4844 100755 --- a/config/homebin/switch_php_debugmod +++ b/config/homebin/switch_php_debugmod @@ -50,7 +50,7 @@ enable_phpmod() { } is_module_enabled_fpm() { - if [ -f "/var/lib/php/modules/${1}/fpm/enabled_by_admin/${2}" ]; then + if [ -f "/var/lib/php/modules/${1}/fpm/enabled_by_admin/${2}" ] || [ -f "/var/lib/php/modules/${1}/fpm/enabled_by_maint/${2}" ]; then return 0 fi return 1 From ecd847c7ad13f74735f28acd0f40b30070f4baf7 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 13 Sep 2022 15:41:50 +0200 Subject: [PATCH 21/47] remove hidden symbols from version validation --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 9dd1e986c..edb1c2a7d 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -46,7 +46,7 @@ function vvv_set_php_cli_version() { php_version=$(readlink -f /usr/bin/php) DEFAULTPHP=$(vvv_get_site_config_value 'php' "${DEFAULTPHP}") if [[ $php_version != *"${DEFAULTPHP}"* ]]; then - length=$(echo "$DEFAULTPHP" | wc -c) + length=$(echo "$DEFAULTPHP" | wc -c | tr '\n' '' | tr '\r' '') if [[ $length > '3' ]]; then vvv_warn " ! Warning: PHP version defined is using a wrong format: '${DEFAULTPHP}' with length '${length}'" else From 468b77f9eb8d63b55d989119a66bd6a6c9547fd3 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 25 Sep 2022 18:33:19 +0100 Subject: [PATCH 22/47] refactor validation and retrieval of the sites PHP value --- provision/provision-site.sh | 55 +++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index edb1c2a7d..45ca72473 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -38,26 +38,47 @@ function vvv_get_site_config_value() { echo "${value}" } +function vvv_get_site_php_version() { + SITE_PHP=$(vvv_get_site_config_value 'php' "${DEFAULTPHP}") + + # remove whitespace + SITE_PHP=$(echo -n "${SITE_PHP}" | xargs | tr -d '\n' | tr -d '\r') + + # Handle when php:8 instead of 8.0 or if it's parsed as a number + if [[ "${#SITE_PHP}" -eq "1" ]]; then + SITE_PHP="${SITE_PHP}.0" + fi + + echo -n "${SITE_PHP}" +} + +vvv_validate_site_php_version() { + SITE_PHP=$(vvv_get_site_php_version) + if [[ "${#SITE_PHP}" > "3" ]]; then + vvv_warn " ! Warning: PHP version defined is using a wrong format: '${SITE_PHP}' with length '${length}'" + vvv_warn " If you are trying to use a more specific version of PHP such as 7.4.1 or 7.4.0 you" + vvv_warn " need to be less specific and use 7.4" + fi + + if [[ ! -e "/usr/bin/php${SITE_PHP}" ]]; then + vvv_warn " ! Warning: Chosen PHP version doesn't exist in this environment: '${SITE_PHP}' looking for '/usr/bin/php${SITE_PHP}'" + fi +} + # @description sets a sites PHP version as the global version, or to the VVV default if none is specified # # @internal # @noargs -function vvv_set_php_cli_version() { - php_version=$(readlink -f /usr/bin/php) - DEFAULTPHP=$(vvv_get_site_config_value 'php' "${DEFAULTPHP}") - if [[ $php_version != *"${DEFAULTPHP}"* ]]; then - length=$(echo "$DEFAULTPHP" | wc -c | tr '\n' '' | tr '\r' '') - if [[ $length > '3' ]]; then - vvv_warn " ! Warning: PHP version defined is using a wrong format: '${DEFAULTPHP}' with length '${length}'" - else - echo " * Setting the default PHP CLI version ( ${DEFAULTPHP} ) for this site" - update-alternatives --set php "/usr/bin/php${DEFAULTPHP}" &> /dev/null - update-alternatives --set phar "/usr/bin/phar${DEFAULTPHP}" &> /dev/null - update-alternatives --set phar.phar "/usr/bin/phar.phar${DEFAULTPHP}" &> /dev/null - update-alternatives --set phpize "/usr/bin/phpize${DEFAULTPHP}" &> /dev/null - update-alternatives --set php-config "/usr/bin/php-config${DEFAULTPHP}" &> /dev/null - fi - fi +function vvv_apply_site_php_cli_version() { + vvv_validate_site_php_version + SITE_PHP=$(vvv_get_site_php_version) + + echo " * Setting the default PHP CLI version ( ${SITE_PHP} ) for this site" + update-alternatives --set php "/usr/bin/php${SITE_PHP}" &> /dev/null + update-alternatives --set phar "/usr/bin/phar${SITE_PHP}" &> /dev/null + update-alternatives --set phar.phar "/usr/bin/phar.phar${SITE_PHP}" &> /dev/null + update-alternatives --set phpize "/usr/bin/phpize${SITE_PHP}" &> /dev/null + update-alternatives --set php-config "/usr/bin/php-config${SITE_PHP}" &> /dev/null } # @description Takes 2 values, a key to fetch a value for, and an optional default value @@ -516,7 +537,7 @@ function vvv_custom_folders() { # ------------------------------- source /srv/config/homebin/vvv_restore_php_default VVV_DEFAULTPHP=$DEFAULT_PHP -vvv_set_php_cli_version +vvv_apply_site_php_cli_version if [[ true == "${SKIP_PROVISIONING}" ]]; then vvv_warn " * Skipping provisioning of ${SITE}" From 22e0ba4ef0f399dab6dcb0a4c7986d94bc47404a Mon Sep 17 00:00:00 2001 From: dwashko Date: Tue, 27 Sep 2022 15:40:05 -0400 Subject: [PATCH 23/47] fix-2634 - adding full path to run vvv_restore_php_default script --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 45ca72473..5175d60e6 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -575,6 +575,6 @@ if [ "${SUCCESS}" -ne "0" ]; then exit 1 fi -vvv_restore_php_default +/srv/config/homebin/vvv_restore_php_default provisioner_success From c725c41188ffaf475a6bd630942c5506e8a0d6e4 Mon Sep 17 00:00:00 2001 From: dwashko Date: Tue, 27 Sep 2022 15:40:05 -0400 Subject: [PATCH 24/47] Fix #2634 - adding full path to run vvv_restore_php_default script --- provision/provision-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 45ca72473..5175d60e6 100755 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -575,6 +575,6 @@ if [ "${SUCCESS}" -ne "0" ]; then exit 1 fi -vvv_restore_php_default +/srv/config/homebin/vvv_restore_php_default provisioner_success From f3fe231dbdd8260eceadaccb62dd32997d5e8b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alda=20Vigd=C3=ADs=20Skarph=C3=A9=C3=B0insd=C3=B3ttir?= Date: Sat, 5 Nov 2022 03:44:21 +0100 Subject: [PATCH 25/47] Fixing faulty Vagrant plugin check This replaces the `Vagrant.has_plugin?` check in the Vagrantfile with `config.vagrant.plugins.include?` as the latter is not available when the script is run. The `else` statement here seems unnecessary as Vagrant checks for installed plugins during `vagrant up`. See also: https://github.com/hashicorp/vagrant/issues/10161 --- CHANGELOG.md | 3 ++- Vagrantfile | 21 +++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f5db3484..f0ae438e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ permalink: /docs/en-US/changelog/ ### Bug Fixes -* .... +* Fixed faulty Vagrant plugin check. + ## 3.10.1 ( 2022 September 10th ) diff --git a/Vagrantfile b/Vagrantfile index a4b0e255b..257693133 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -851,29 +851,26 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # located in the www/ directory and in config/config.yml. # - if Vagrant.has_plugin?('vagrant-goodhosts') + if config.vagrant.plugins.include? 'vagrant-goodhosts' config.goodhosts.aliases = vvv_config['hosts'] config.goodhosts.remove_on_suspend = true - elsif Vagrant.has_plugin?('vagrant-hostsmanager') + elsif config.vagrant.plugins.include? 'vagrant-hostsmanager' config.hostmanager.aliases = vvv_config['hosts'] config.hostmanager.enabled = true config.hostmanager.manage_host = true config.hostmanager.manage_guest = true config.hostmanager.ignore_private_ip = false config.hostmanager.include_offline = true - elsif Vagrant.has_plugin?('vagrant-hostsupdater') + elsif config.vagrant.plugins.include? 'vagrant-hostsupdater' # Pass the found host names to the hostsupdater plugin so it can perform magic. config.hostsupdater.aliases = vvv_config['hosts'] config.hostsupdater.remove_on_suspend = true - else - show_check = true if %w[up halt resume suspend status provision reload].include? ARGV[0] - if show_check - puts "" - puts " X ! There is no hosts file vagrant plugin installed!" - puts " X You need the vagrant-goodhosts plugin (or HostManager/ HostsUpdater ) for domains to work in the browser" - puts " X Run 'vagrant plugin install --local' to fix this." - puts "" - end + elsif %w[up halt resume suspend status provision reload].include? ARGV[0] + puts "" + puts " X ! There is no hosts file vagrant plugin installed!" + puts " X You need the vagrant-goodhosts plugin (or HostManager/ HostsUpdater ) for domains to work in the browser" + puts " X Run 'vagrant plugin install --local' to fix this." + puts "" end # Vagrant Triggers From 7e5ec1d861be617fdf783b751ff6716236503ccd Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 13 Nov 2022 17:05:56 +0000 Subject: [PATCH 26/47] move the fallback config and adjust site provisioning so it does not fail or abort --- .../fallback.conf => site-fallback.conf} | 0 provision/provision-site.sh | 26 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) rename provision/core/nginx/config/{sites/fallback.conf => site-fallback.conf} (100%) diff --git a/provision/core/nginx/config/sites/fallback.conf b/provision/core/nginx/config/site-fallback.conf similarity index 100% rename from provision/core/nginx/config/sites/fallback.conf rename to provision/core/nginx/config/site-fallback.conf diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 7af283393..a7aa83a48 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -23,7 +23,7 @@ NGINX_UPSTREAM=$6 VVV_PATH_TO_SITE=${VM_DIR} # used in site templates VVV_SITE_NAME=${SITE} VVV_HOSTS="" -SUCCESS=1 +SUCCESS=0 VVV_CONFIG=/vagrant/config.yml @@ -136,15 +136,11 @@ function vvv_provision_site_nginx_config() { local SITE_NAME=$1 local SITE_NGINX_FILE=$2 - if [ ! -f "$SITE_NGINX_FILE" ]; then - vvv_warn " * VVV didn't found any Nginx config file, it will use a fallback config file" - cp -f "/srv/provision/core/nginx/config/sites/fallback.conf" "$SITE_NGINX_FILE" - fi local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} - local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} - local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} - local DEST_NGINX_FILE="vvv-auto-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-32).conf" - + DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} + DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} + DEST_NGINX_FILE="vvv-auto-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-32).conf" + VVV_HOSTS=$(get_hosts) local TMPFILE=$(mktemp /tmp/vvv-site-XXXXX) cat "${SITE_NGINX_FILE}" >> "${TMPFILE}" @@ -190,8 +186,10 @@ function vvv_provision_site_nginx_config() { # "/etc/nginx/custom-sites/${DEST_NGINX_FILE}" local DEST_NGINX_FILE=${SITE_NGINX_FILE//\/srv\/www\//} local DEST_NGINX_FILE=${DEST_NGINX_FILE//\//\-} + local DEST_NGINX_FILE=${DEST_NGINX_FILE//-srv-provision-core-nginx-config-/\-} local DEST_NGINX_FILE=${DEST_NGINX_FILE//-provision/} # remove the provision folder name local DEST_NGINX_FILE=${DEST_NGINX_FILE//-.vvv/} # remove the .vvv folder name + #local DEST_NGINX_FILE=${DEST_NGINX_FILE//\-\-/\-} local DEST_NGINX_FILE=${DEST_NGINX_FILE/%-vvv-nginx.conf/} local DEST_NGINX_FILE="vvv-${DEST_NGINX_FILE}-$(md5sum <<< "${SITE_NGINX_FILE}" | cut -c1-8).conf" @@ -199,6 +197,7 @@ function vvv_provision_site_nginx_config() { vvv_warn " ! This sites nginx config had problems, it may not load. Look at the above errors to diagnose the problem" vvv_info " ! VVV will now continue with provisioning so that other sites have an opportunity to run" fi + vvv_success " * Installed ${DEST_NGINX_FILE}" rm -f "${TMPFILE}" } @@ -380,20 +379,19 @@ function vvv_provision_site_nginx() { elif [[ -f "${VM_DIR}/vvv-nginx.conf" ]]; then vvv_provision_site_nginx_config "${SITE}" "${VM_DIR}/vvv-nginx.conf" else - vvv_warn " ! Warning: An nginx config was not found!! VVV needs an Nginx config for the site or it will not know how to serve it." - vvv_warn " * VVV searched for an Nginx config in these locations:" + vvv_warn " * VVV searched and did not find an Nginx config in these locations:" vvv_warn " - ${VM_DIR}/.vvv/vvv-nginx.conf" vvv_warn " - ${VM_DIR}/provision/vvv-nginx.conf" vvv_warn " - ${VM_DIR}/vvv-nginx.conf" vvv_warn " * VVV will search 3 folders down to find an Nginx config, please be patient..." local NGINX_CONFIGS=$(find "${VM_DIR}" -maxdepth 3 -name 'vvv-nginx.conf'); if [[ -z $NGINX_CONFIGS ]] ; then - vvv_error " ! Error: No nginx config was found, VVV will not know how to serve this site" - exit 1 + vvv_warn " * VVV did not found an Nginx config file, it will use a fallback config file." + noroot mkdir -p "${VM_DIR}/log" + vvv_provision_site_nginx_config "${SITE}" "/srv/provision/core/nginx/config/site-fallback.conf" else vvv_warn " * VVV found Nginx config files in subfolders, move these files to the expected locations to avoid these warnings." for SITE_CONFIG_FILE in $NGINX_CONFIGS; do - vvv_info vvv_provision_site_nginx_config "${SITE}" "${SITE_CONFIG_FILE}" done fi From 0589180d3478ae7a550d3304b926b46a389d7970 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 13 Nov 2022 17:09:51 +0000 Subject: [PATCH 27/47] fix missing public_html --- provision/core/nginx/config/site-fallback.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/core/nginx/config/site-fallback.conf b/provision/core/nginx/config/site-fallback.conf index fb8becd8e..bd7e79621 100644 --- a/provision/core/nginx/config/site-fallback.conf +++ b/provision/core/nginx/config/site-fallback.conf @@ -2,7 +2,7 @@ server { listen 80; listen 443 ssl http2; server_name {vvv_hosts}; - root "{vvv_path_to_site}{vvv_public_dir}"; + root "{vvv_path_to_site}/public_html"; # Nginx logs error_log "{vvv_path_to_site}/log/nginx-error.log"; From 012f6cc4cdb42966d591c2da38849a92b471618e Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 13 Nov 2022 17:14:31 +0000 Subject: [PATCH 28/47] update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0ae438e2..e4815f1cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,13 +10,13 @@ permalink: /docs/en-US/changelog/ ### Enhancements -* .... +* Added a fallback Nginx config for sites that don't specify a site provisioner ( #2279 ) + * Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. ### Bug Fixes * Fixed faulty Vagrant plugin check. - ## 3.10.1 ( 2022 September 10th ) ### Enhancements From 67695e74bf4296a087ad8b9f2bd05731d6049121 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sat, 3 Dec 2022 20:25:08 +0000 Subject: [PATCH 29/47] Enforce Goodhosts Disable Clean Theoretically a user might be using an older version that cleans by default --- Vagrantfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index 9db59454e..aced7810a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -867,6 +867,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if config.vagrant.plugins.include? 'vagrant-goodhosts' config.goodhosts.aliases = vvv_config['hosts'] config.goodhosts.remove_on_suspend = true + + # goodhosts already disables clean by default, but lets enforce this at both ends + config.goodhosts.disable_clean = false elsif config.vagrant.plugins.include? 'vagrant-hostsmanager' config.hostmanager.aliases = vvv_config['hosts'] config.hostmanager.enabled = true From bd2035302efe18534f9e8a8cdbf41c99e7392cc3 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sun, 4 Dec 2022 00:21:55 +0000 Subject: [PATCH 30/47] disable cleaning in goodhosts --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index aced7810a..c86ff5bc9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -869,7 +869,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.goodhosts.remove_on_suspend = true # goodhosts already disables clean by default, but lets enforce this at both ends - config.goodhosts.disable_clean = false + config.goodhosts.disable_clean = true elsif config.vagrant.plugins.include? 'vagrant-hostsmanager' config.hostmanager.aliases = vvv_config['hosts'] config.hostmanager.enabled = true From 5e12ec27505ee2c2aa7d204f3b30ba5d221cbb1a Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 6 Dec 2022 20:06:02 +0000 Subject: [PATCH 31/47] php parameter fixes for sites --- provision/provision-site.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index a7aa83a48..679b9cf39 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -25,6 +25,8 @@ VVV_SITE_NAME=${SITE} VVV_HOSTS="" SUCCESS=0 +DEFAULTPHP="7.4" + VVV_CONFIG=/vagrant/config.yml . "/srv/provision/provisioners.sh" @@ -157,8 +159,9 @@ function vvv_provision_site_nginx_config() { sed -i "s#{vvv_hosts}#${VVV_HOSTS}#" "${TMPFILE}" # if php: is configured, set the upstream to match - if [ "${DEFAULTPHP}" != "${VVV_DEFAULTPHP}" ]; then - NGINX_UPSTREAM="php${DEFAULTPHP}" + SITE_PHP=$(vvv_get_site_php_version) + if [ "${DEFAULTPHP}" != "${SITE_PHP}" ]; then + NGINX_UPSTREAM="php${SITE_PHP}" NGINX_UPSTREAM=$(echo "$NGINX_UPSTREAM" | tr --delete .) fi From 9f89f6f2111865d113fc38c57f7f60e3cb2c9828 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 6 Dec 2022 20:07:47 +0000 Subject: [PATCH 32/47] remove unnecessary VVV_DEFAULTPHP --- provision/provision-site.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/provision/provision-site.sh b/provision/provision-site.sh index 679b9cf39..0fde26da2 100644 --- a/provision/provision-site.sh +++ b/provision/provision-site.sh @@ -547,7 +547,6 @@ function vvv_custom_folders() { # ------------------------------- source /srv/config/homebin/vvv_restore_php_default -VVV_DEFAULTPHP=$DEFAULT_PHP vvv_apply_site_php_cli_version if [[ true == "${SKIP_PROVISIONING}" ]]; then From 692ca032b9b10a8009527cb7696039f6821f533e Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 6 Dec 2022 20:08:37 +0000 Subject: [PATCH 33/47] update changelog with php site version fix --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4815f1cf..33838f3e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,12 @@ permalink: /docs/en-US/changelog/ ### Enhancements * Added a fallback Nginx config for sites that don't specify a site provisioner ( #2279 ) - * Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. +* Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. ### Bug Fixes * Fixed faulty Vagrant plugin check. +* A fix for setting the PHP version parameter ( #2644 ) ## 3.10.1 ( 2022 September 10th ) @@ -24,7 +25,7 @@ permalink: /docs/en-US/changelog/ * Improved provisioning output * VVV will now attempt to test Nginx configs on installation and recover ( #2604 ) * Switched to new launchpad PPA domains with HTTPS ( #2586 ) -* Improved the verboseness of the DB import scripts ( #2621 ) +* Improved the verboseness of the DB import scripts ( #2621 ) * PHP version parameter for provisioner and Nginx ( #2583 ) ### Bug Fixes From c9a6c514150e09009aedafd9962e1ec5b4bffee5 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Mon, 26 Dec 2022 18:45:20 +0000 Subject: [PATCH 34/47] Fix ifconfig check --- provision/provision-helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/provision-helpers.sh b/provision/provision-helpers.sh index 57d5bcf0a..d5018038b 100755 --- a/provision/provision-helpers.sh +++ b/provision/provision-helpers.sh @@ -136,7 +136,7 @@ function network_check() { vvv_error "provisioning involves downloading things, a full provision may " vvv_error "ruin the wifi for everybody else :(" vvv_error " " - if ! command -v ifconfig &> /dev/null; then + if command -v ifconfig &> /dev/null; then vvv_error "Network ifconfig output:" vvv_error " " ifconfig From 970b9e32de66e6e5dca3e0529633cf28c737cce0 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 27 Dec 2022 18:02:13 +0000 Subject: [PATCH 35/47] remove unnecessary local variable command_exist --- provision/core/deprecated.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/provision/core/deprecated.sh b/provision/core/deprecated.sh index f3f16293e..7e5c94589 100644 --- a/provision/core/deprecated.sh +++ b/provision/core/deprecated.sh @@ -4,7 +4,6 @@ # @description Check if we're on Ubuntu 14 and abort provisioning # @noargs function deprecated_distro() { - local command_exist if ! command -v lsb_release &> /dev/null; then return 0 fi From 72deafd09166399ef854ea4e1b898263b533fc72 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 27 Dec 2022 20:58:13 +0000 Subject: [PATCH 36/47] bump phpcompatibility-wp --- provision/core/phpcs/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/core/phpcs/composer.json b/provision/core/phpcs/composer.json index 9b19eb76b..482fe948a 100644 --- a/provision/core/phpcs/composer.json +++ b/provision/core/phpcs/composer.json @@ -15,7 +15,7 @@ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", "automattic/vipwpcs": "^2.3.3", "phpcompatibility/php-compatibility": "^9.3.5", - "phpcompatibility/phpcompatibility-wp": "^2.1.3" + "phpcompatibility/phpcompatibility-wp": "^2.1.4" }, "config": { "allow-plugins": { From b8f7feac1997f463e2d6df0019b6fa8a7ee479d5 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 27 Dec 2022 21:02:55 +0000 Subject: [PATCH 37/47] Update composer.json --- provision/core/phpcs/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/provision/core/phpcs/composer.json b/provision/core/phpcs/composer.json index 482fe948a..b5a018169 100644 --- a/provision/core/phpcs/composer.json +++ b/provision/core/phpcs/composer.json @@ -20,6 +20,7 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true - } + }, + "bin-dir": "bin/" } } From d64a59009052c439521fa056285c637550bfdaf0 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 27 Dec 2022 21:03:54 +0000 Subject: [PATCH 38/47] remove the composer bin dir constant as it's set in the composer.json now --- provision/core/phpcs/provision.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/core/phpcs/provision.sh b/provision/core/phpcs/provision.sh index 5ddb0a730..c107a360c 100644 --- a/provision/core/phpcs/provision.sh +++ b/provision/core/phpcs/provision.sh @@ -19,7 +19,7 @@ function php_codesniff_setup() { noroot mkdir -p /srv/www/phpcs noroot cp -f "/srv/provision/core/phpcs/composer.json" "/srv/www/phpcs/composer.json" cd /srv/www/phpcs - COMPOSER_BIN_DIR="bin" noroot composer update --no-ansi --no-progress + noroot composer update --no-ansi --no-progress vvv_info " * [PHPCS]: Setting WordPress-Core as the default PHPCodesniffer standard" From e79ecfa3b2afd3495ce5cc7c43f621c855ae80aa Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 27 Dec 2022 21:15:52 +0000 Subject: [PATCH 39/47] add no dev to the composer update command --- provision/core/phpcs/provision.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/core/phpcs/provision.sh b/provision/core/phpcs/provision.sh index c107a360c..ea7244149 100644 --- a/provision/core/phpcs/provision.sh +++ b/provision/core/phpcs/provision.sh @@ -19,7 +19,7 @@ function php_codesniff_setup() { noroot mkdir -p /srv/www/phpcs noroot cp -f "/srv/provision/core/phpcs/composer.json" "/srv/www/phpcs/composer.json" cd /srv/www/phpcs - noroot composer update --no-ansi --no-progress + noroot composer update --no-ansi --no-progress --no-dev vvv_info " * [PHPCS]: Setting WordPress-Core as the default PHPCodesniffer standard" From 92ae7349795f92a9d9fd3147b7c0f5def8676800 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Sat, 31 Dec 2022 16:42:00 +0000 Subject: [PATCH 40/47] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33838f3e3..c58dcab32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ permalink: /docs/en-US/changelog/ * Added a fallback Nginx config for sites that don't specify a site provisioner ( #2279 ) * Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. +* Simplified PHPCS installation bin dir setting ( #2648 ) ### Bug Fixes From 624f89bce78f7c0871976867661ea6a258718727 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 3 Jan 2023 14:15:35 +0000 Subject: [PATCH 41/47] update bug report --- .github/ISSUE_TEMPLATE/bug-report.yml | 31 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index b88615515..28faf9a10 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -6,20 +6,21 @@ body: - type: dropdown id: version attributes: - label: Are you using the latest stable or develop branch version of VVV? - description: Newer versions of VVV may have fixed your problem already. + label: "Are you using the latest stable or develop branch version of VVV?" + description: "Newer versions of VVV may have fixed your problem already. The `master` branch is unsupported." multiple: false options: - 'Yes (develop)' - 'Yes (stable)' - 'No' + - 'No (unsupported master branch)' - "Don't know" validations: required: true - type: dropdown id: new_or_existng attributes: - label: Is it a new VVV or an existing VVV that used to work? + label: Is it a new VVV, or an existing VVV that used to work? multiple: false options: - 'Existing, worked but now broken' @@ -27,11 +28,23 @@ body: - "Don't know" validations: required: true + - type: dropdown + id: customfiles + attributes: + label: "Did you use a CustomFile?" + description: "Some people add a `CustomFile` to make unsupported vagrant modifications. If you did this you must share what you changed in the issue." + multiple: false + options: + - 'No (default)' + - 'Yes' + - "Don't know" + validations: + required: true - type: textarea attributes: label: Whats the problem? description: | - Be as descriptive as possible!!! + Be as descriptive as possible!!! Include the output log, including lines above and below it. Most of the waiting time is us waiting for issue reporters to share the full log. validations: required: true - type: textarea @@ -43,10 +56,10 @@ body: required: false - type: textarea attributes: - label: VVV Status screen + label: "What is the output of `vagrant status`" render: shell description: | - Run `vagrant status` and copy paste the result here + Run `vagrant status` and copy paste the result here, this has a lot of important debug data, if you do not include it we will still ask for it regardless. placeholder: | __ __ __ __ \ V\ V\ V / v1.2.3 Path:"/Users/janedoe/vvv-local" @@ -64,7 +77,7 @@ body: multiple: false options: - 'Apple MacOS (Intel)' - - 'Apple MacOS (Arm/Apple Silicon)' + - 'Apple MacOS (Arm64/Apple Silicon)' - 'Microsoft Windows' - 'Linux' - 'Other' @@ -76,7 +89,9 @@ body: label: Which provider are you using? multiple: false options: - - 'VirtualBox' + - 'VirtualBox 7' + - 'VirtualBox 6' + - 'VirtualBox 5' - 'Parallels (Intel)' - 'Parallels (Apple Silicon/Arm)' - 'Hyper-V' From fb684b5d47b59fed04749b8fa13d24a9bb676278 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Mon, 16 Jan 2023 18:50:36 +0000 Subject: [PATCH 42/47] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c58dcab32..9ba807fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ permalink: /docs/en-US/changelog/ * Added a fallback Nginx config for sites that don't specify a site provisioner ( #2279 ) * Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. * Simplified PHPCS installation bin dir setting ( #2648 ) +* Virtualbox users running `sudo vagrant` commands now get a warning ### Bug Fixes From 56e9ff31140523ee092f8045d47fdd7d7400fd1a Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Fri, 24 Feb 2023 09:24:16 +0000 Subject: [PATCH 43/47] improve network check text --- provision/provision-helpers.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/provision/provision-helpers.sh b/provision/provision-helpers.sh index d5018038b..3e5fad11b 100755 --- a/provision/provision-helpers.sh +++ b/provision/provision-helpers.sh @@ -114,16 +114,16 @@ function network_check() { if (( ${#failed_hosts[@]} )); then vvv_error "#################################################################" vvv_error " " - vvv_error "! Network Problem:" + vvv_error "! Warning! Network Problems:" vvv_error " " - vvv_error "VVV tried to check several domains it needs to provision but ${#failed_hosts[@]} of ${#hosts_to_test[@]} failed:" + vvv_error "VVV tried to check several domains it needs for provisioning but ${#failed_hosts[@]} of ${#hosts_to_test[@]} failed:" vvv_error " " for url in "${hosts_to_test[@]}"; do echo -e "${CRESET} [${RED}x${CRESET}] ${url}${RED}|" done vvv_error " " vvv_error "Make sure you have a working internet connection, that you " - vvv_error "restarted after installing VirtualBox and Vagrant, and that " + vvv_error "restarted after installing VirtualBox/Parallels/Vagrant, and that " vvv_error "they aren't blocked by a firewall or security software." vvv_error "If you can load the address in your browser, then VVV should" vvv_error "be able to connect." @@ -142,13 +142,13 @@ function network_check() { ifconfig vvv_error " " fi - vvv_error "Aborting provision. " vvv_error "Try provisioning again once network connectivity is restored." - vvv_error "If that doesn't work, and you're sure you have a strong " + vvv_error "If that doesn't work, and you're sure you have no VPNs and a strong " vvv_error "internet connection, open an issue on GitHub, and include the " vvv_error "output above so that the problem can be debugged" vvv_error " " - vvv_error "vagrant reload --provision" + vvv_error "vagrant halt" + vvv_error "vagrant up --provision" vvv_error " " vvv_error "https://github.com/Varying-Vagrant-Vagrants/VVV/issues" vvv_error " " From d8081770f67a4b117ed80f23b7914bbf932c674d Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Fri, 24 Feb 2023 10:11:52 +0000 Subject: [PATCH 44/47] add composer bin dir to path, closes #2588 --- provision/core/env/homedir/.bash_aliases | 6 ++++++ provision/core/env/homedir/.bash_profile | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/provision/core/env/homedir/.bash_aliases b/provision/core/env/homedir/.bash_aliases index 3393c1949..171672391 100644 --- a/provision/core/env/homedir/.bash_aliases +++ b/provision/core/env/homedir/.bash_aliases @@ -39,6 +39,12 @@ if [ -d "$HOME/.gem/bin" ] ; then fi fi +if [ -d "$HOME/.config/composer/vendor/bin" ] ; then + if [[ $PATH != *"${HOME}/.config/composer/vendor/bin"* ]]; then + export PATH="$PATH:${HOME}/.config/composer/vendor/bin" + fi +fi + # Vagrant scripts if [[ $PATH != *"/srv/config/homebin"* ]]; then export PATH="$PATH:/srv/config/homebin" diff --git a/provision/core/env/homedir/.bash_profile b/provision/core/env/homedir/.bash_profile index 8d67323c2..49c6fc610 100644 --- a/provision/core/env/homedir/.bash_profile +++ b/provision/core/env/homedir/.bash_profile @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # bash_profile # # Symlinked to the vagrant user's home directory. This loads @@ -29,8 +30,8 @@ PS1="${debian_chroot:+($debian_chroot)}${red}\u${green}@${blue}\h${white}:${yell # setup bash prompt if [ -n "$BASH_VERSION" ]; then # include .bash_prompt if it exists - if [ -f "$HOME/.bash_prompt" ]; then - . "$HOME/.bash_prompt" + if [ -f "${HOME}/.bash_prompt" ]; then + . "${HOME}/.bash_prompt" fi fi From 1f502112746408efcab093c7771c19d4854c4b8f Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Fri, 24 Feb 2023 10:12:28 +0000 Subject: [PATCH 45/47] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba807fb6..352570538 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ permalink: /docs/en-US/changelog/ * Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. * Simplified PHPCS installation bin dir setting ( #2648 ) * Virtualbox users running `sudo vagrant` commands now get a warning +* Added composer bin directory to path ( #2588 ) ### Bug Fixes From ea2e3dfb1dee95b876febb9e96cfd7393182f333 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Fri, 24 Feb 2023 09:50:00 +0000 Subject: [PATCH 46/47] fix setting git rebase pull config value for non-root users --- CHANGELOG.md | 1 + provision/core/git/provision.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba807fb6..0fef262b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ permalink: /docs/en-US/changelog/ * Sites that do not have a provisioner set will have a logs folder created for Nginx logs,and a public_html folder with Nginx rules for WordPress or other PHP applications. The user is responsible for creating a database and installing/placing a site. * Simplified PHPCS installation bin dir setting ( #2648 ) * Virtualbox users running `sudo vagrant` commands now get a warning +* Fixed setting of git rebase config for the vagrant nonroot user ( #2658 ) ### Bug Fixes diff --git a/provision/core/git/provision.sh b/provision/core/git/provision.sh index f8576c575..fcc99e37d 100644 --- a/provision/core/git/provision.sh +++ b/provision/core/git/provision.sh @@ -54,5 +54,9 @@ function git_after_packages() { vvv_info " * Git hasn't been told how to merge branches, setting pull.rebase false for the merge strategy" git config --global pull.rebase false fi + if ! noroot git config --global pull.rebase; then + vvv_info " * Git hasn't been told how to merge branches, setting pull.rebase false for the merge strategy" + noroot git config --global pull.rebase false + fi } vvv_add_hook after_packages git_after_packages From 80d455561b3e87debea64aacacb6161b0bb31e0e Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Tue, 14 Mar 2023 22:27:11 +0000 Subject: [PATCH 47/47] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c08bc05..e35581224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ permalink: /docs/en-US/changelog/ # Changelog -## 3.11.0 ( WIP ) +## 3.11.0 ( 2023 March 14th ) ### Enhancements