Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjn committed Sep 10, 2022
2 parents fabccb8 + 774b58e commit 5b3aa20
Show file tree
Hide file tree
Showing 25 changed files with 287 additions and 95 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ permalink: /docs/en-US/changelog/

# Changelog

## 3.10.1 ( 2022 September 10th )

### Enhancements

* 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 )

### Bug Fixes

* WP CLI package update failures now fail gracefully instead of stopping a provision ( #2601 )
* Fixed an edge case updating NVM via git ( #2604 )
* Disable hardware support for gcrypt to avoid bad VirtualBox implementations ( #2609 )
* Fix unbound variable in `db_backup` ( #2617 )
* Ensured npm and nvm are always available in site provisioners
* Explicitly allow a composer plugin when installing PHPCS to avoid issues in July 2022 ( #2620 )

## 3.9.1 ( 2022 April 13th )

### Enhancements
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# VVV ( Varying Vagrant Vagrants )
# VVV

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/206b06167aaf48aab24422cd417e8afa)](https://www.codacy.com/gh/Varying-Vagrant-Vagrants/VVV?utm_source=github.com&utm_medium=referral&utm_content=Varying-Vagrant-Vagrants/VVV&utm_campaign=Badge_Grade) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/varying-vagrant-vagrants/vvv.svg)](http://isitmaintained.com/project/varying-vagrant-vagrants/vvv "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/varying-vagrant-vagrants/vvv.svg)](http://isitmaintained.com/project/varying-vagrant-vagrants/vvv "Percentage of issues still open")

VVV is a local developer environment, mainly aimed at [WordPress](https://wordpress.org) developers. It uses [Vagrant](https://www.vagrantup.com) and VirtualBox, and can be used to build sites, and contribute to WordPress.
VVV is a local developer environment, mainly aimed at [WordPress](https://wordpress.org) developers. It uses [Vagrant](https://www.vagrantup.com) and VirtualBox/Parallels/HyperV to create a linux server environment for building sites, and contributing to WordPress itself.

_VVV stands for Varying Vagrant Vagrants._

## How To Use

Expand Down
22 changes: 13 additions & 9 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if show_logo

splashfirst = <<~HEREDOC
\033[1;38;5;196m#{red}__ #{green}__ #{blue}__ __
#{red}\\ V#{green}\\ V#{blue}\\ V / #{purple}v#{version} #{purple}Path:"#{vagrant_dir}"
#{red}\\ V#{green}\\ V#{blue}\\ V / #{purple}v#{version} #{purple}Ruby:#{RUBY_VERSION}, Path:"#{vagrant_dir}"
#{red} \\_/#{green}\\_/#{blue}\\_/ #{creset}#{branch_c}#{git_or_zip}#{branch}#{commit}#{creset}
HEREDOC
Expand Down Expand Up @@ -354,7 +354,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Configuration options for the Parallels provider.
config.vm.provider :parallels do |v|
v.update_guest_tools = true
v.customize ['set', :id, '--longer-battery-life', 'off']
v.memory = vvv_config['vm_config']['memory']
v.cpus = vvv_config['vm_config']['cores']
Expand Down Expand Up @@ -408,13 +407,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'bento/ubuntu-20.04'
config.vm.box_check_update = false

# If we're at a contributor day, switch the base box to the prebuilt one
if defined? vvv_config['vm_config']['wordcamp_contributor_day_box']
if vvv_config['vm_config']['wordcamp_contributor_day_box'] == true
config.vm.box = 'vvv/contribute'
end
end

# The Parallels Provider uses a different naming scheme.
config.vm.provider :parallels do |_v, override|
override.vm.box = 'bento/ubuntu-20.04'
Expand All @@ -438,6 +430,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
override.vm.box = 'bento/ubuntu-20.04'
end

# Virtualbox.
config.vm.provider :virtualbox do |_v, override|
override.vm.box = 'bento/ubuntu-20.04'

# If we're at a contributor day, switch the base box to the prebuilt one
if defined? vvv_config['vm_config']['wordcamp_contributor_day_box']
if vvv_config['vm_config']['wordcamp_contributor_day_box'] == true
override.vm.box = 'vvv/contribute'
end
end
end

if defined? vvv_config['vm_config']['box']
unless vvv_config['vm_config']['box'].nil?
config.vm.box = vvv_config['vm_config']['box']
Expand Down
22 changes: 13 additions & 9 deletions config/homebin/db_backup
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# are imported automatically during an initial provision if
# the databases exist per the import-sql.sh process.
set -eo pipefail
set -u

if [ -z "${VVV_LOG+x}" ]; then
export VVV_LOG=""
fi

trap 'rm -rf $TMPFIFODIR' EXIT; TMPFIFODIR=$(mktemp -d); mkfifo $TMPFIFODIR/dbnames

Expand All @@ -16,14 +21,13 @@ gzip=$(get_config_value "general.db_backup.gzip")
exclude_list=$(get_config_values "general.db_backup.exclude")

vvv_info " * Fetching Database names"
mysql --user="root" --password="root" -e 'show databases' | \
grep -v -F "Database" > $TMPFIFODIR/dbnames &
while read db_name
do
mysql -e 'show databases' | grep -v -F "Database" > $TMPFIFODIR/dbnames &
while read db_name; do
# skip these databases
[ "${db_name}" == "mysql" ] && vvv_info " - skipped <b>${db_name}</b>" && continue;
[ "${db_name}" == "information_schema" ] && vvv_info " - skipped <b>${db_name}</b>" && continue;
[ "${db_name}" == "performance_schema" ] && vvv_info " - skipped <b>${db_name}</b>" && continue;
[ "${db_name}" == "sys" ] && vvv_info " - skipped <b>${db_name}</b>" && continue;
[ "${db_name}" == "test" ] && vvv_info " - skipped ${db_name}" && continue;
[ "${db_name}" == "wordpress_unit_tests" ] && vvv_info " - skipped <b>${db_name}</b>" && continue;

Expand All @@ -35,12 +39,12 @@ do
done

if [ ${skip} == "true" ]; then
vvv_info " - skipped <b>${db_name}</b>" && continue;
vvv_info " - excluded <b>${db_name}</b>" && continue;
fi

# don't back up databases with no tables
mysql_cmd="SHOW TABLES FROM \`${db_name}\`" # Required to support hyphens in database names
db_exist=$(mysql -u root -proot --skip-column-names -e "${mysql_cmd}")
db_exist=$(mysql --skip-column-names -e "${mysql_cmd}")
if [ "$?" == "0" ]; then
if [ "" == "${db_exist}" ]; then
vvv_info " - skipped <b>${db_name}</b><info>, no tables in database to back up</info>" && continue;
Expand All @@ -53,15 +57,15 @@ ext=".sql"
if [[ "${gzip}" == "True" ]]; then
ext=".sql.gz"
fi
count=0
count=1
for db in "${databases[@]}"
do
OUTPUT=$(printf "<info> - %2s/%s Backing up </info><b>%-23s</b><info> to </info><b>'database/backups/%s${ext}'</b>" "${count}" "${#databases[@]}" "'${db}'" "${db}")
vvv_output "${OUTPUT}"
if [[ "${gzip}" == "True" ]]; then
mysqldump -uroot -proot "${db}" | gzip > "/srv/database/backups/${db}.sql.gz"
mysqldump "${db}" | gzip > "/srv/database/backups/${db}.sql.gz"
else
mysqldump -uroot -proot "${db}" > "/srv/database/backups/${db}.sql";
mysqldump "${db}" > "/srv/database/backups/${db}.sql";
fi
let "count=count+1"
done
Expand Down
2 changes: 1 addition & 1 deletion config/homebin/db_restore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#
# Restore individual SQL files for each database.
/srv/database/import-sql.sh
. /srv/database/import-sql.sh
2 changes: 1 addition & 1 deletion config/homebin/vagrant_provision
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ else
# List failed provisioners, and pipe them through xargs to print them in a formatted way.
ls -A /vagrant/failed_provisioners/ | xargs -I "LOGFILE" echo -e " - <b>log/provisioners/${date_time}/LOGFILE.log</b>"
echo -e "${RED} ──────────────────────────────────────────────────${CRESET}"
fi
fi
4 changes: 2 additions & 2 deletions config/init/vvv-start.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# varying-vagrant-vagrants - necessary services at start
# vvv - necessary services at start

description "necessary services for Varying Vagrant Vagrants"
description "necessary services for VVV"

start on runlevel [2345]

Expand Down
64 changes: 58 additions & 6 deletions database/sql/import-sql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
# through {vvv-dir}/database/data
#
# Let's begin...
set -eo pipefail
set -u

if [ -z "${VVV_LOG+x}" ]; then
export VVV_LOG=""
fi

source /srv/provision/provision-helpers.sh

Expand All @@ -25,6 +31,26 @@ if [[ -f /srv/config/config.yml ]]; then
VVV_CONFIG=/srv/config/config.yml
fi

FORCE_RESTORE="0"
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-f|--force) # quick mode
FORCE_RESTORE="1"
shift # past argument
;;
--*|-*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters

run_restore=$(shyaml get-value general.db_restore 2> /dev/null < ${VVV_CONFIG})
exclude_list=$(get_config_values "general.db_restore.exclude")
include_list=$(get_config_values "general.db_restore.include")
Expand All @@ -48,6 +74,7 @@ IFS=$(echo -en "\n\b")
# Parse through each file in the directory and use the file name to
# import the SQL file into the database of the same name
sql_count=$(ls -1 ./*.sql* 2>/dev/null | wc -l)
vvv_info " * Found ${sql_count} database dumps"
if [ "$sql_count" != 0 ]
then
for file in $( ls ./*.sql* )
Expand All @@ -62,9 +89,31 @@ then
[ "${db_name}" == "mysql" ] && continue;
[ "${db_name}" == "information_schema" ] && continue;
[ "${db_name}" == "performance_schema" ] && continue;
[ "${db_name}" == "sys" ] && continue;
[ "${db_name}" == "test" ] && continue;

vvv_info " * Creating the <b>${db_name}</b><info> database if it doesn't already exist, and granting the wp user access"
vvv_info " * Processing ${db_name} dump"

# if we specified databases, only restore specified ones
if [[ "${#@}" -gt 0 ]]; then
FOUND=0
for var in "$@"; do
if [[ "${var}" == "${db_name}" ]]; then
FOUND=1
break;
fi
done
if [[ "${FOUND}" -eq 0 ]]; then
continue;
fi
fi

if [ "1" == "${FORCE_RESTORE}" ]; then
vvv_info " * Forcing restore of <b>${db_name}</b><info> database, and granting the wp user access"
mysql -e "DROP DATABASE IF EXISTS \`${db_name}\`"
else
vvv_info " * Creating the <b>${db_name}</b><info> database if it doesn't already exist, and granting the wp user access"
fi

skip="false"

Expand All @@ -77,14 +126,15 @@ then
skip="true"
fi
done

for include in ${include_list[@]}; do
if [ "${include}" == "${db_name}" ]; then
skip="false"
fi
done

mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS \`${db_name}\`"
mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON \`${db_name}\`.* TO wp@localhost IDENTIFIED BY 'wp';"
mysql -e "CREATE DATABASE IF NOT EXISTS \`${db_name}\`"
mysql -e "GRANT ALL PRIVILEGES ON \`${db_name}\`.* TO wp@localhost IDENTIFIED BY 'wp';"

[ "${db_name}" == "wordpress_unit_tests" ] && continue;

Expand All @@ -93,17 +143,17 @@ then
fi

mysql_cmd="SHOW TABLES FROM \`${db_name}\`" # Required to support hyphens in database names
db_exist=$(mysql -u root -proot --skip-column-names -e "${mysql_cmd}")
db_exist=$(mysql --skip-column-names -e "${mysql_cmd}")
if [ "$?" != "0" ]
then
vvv_error " * Error - Create the <b>${db_name}</b><error> database via init-custom.sql before attempting import"
else
if [ "" == "${db_exist}" ]; then
vvv_info " * Importing <b>${db_name}</b><info> from <b>${file}</b>"
if [ "${file: -3}" == ".gz" ]; then
gunzip < "${file}" | mysql -u root -proot "${db_name}"
gunzip < "${file}" | mysql "${db_name}"
else
mysql -u root -proot "${db_name}" < "${file}"
mysql "${db_name}" < "${file}"
fi
vvv_success " * Import of <b>'${db_name}'</b><success> successful</success>"
else
Expand All @@ -116,4 +166,6 @@ else
vvv_success " * No custom databases to import"
fi

vvv_success " * Database importing finished"

IFS=$SAVEIFS
1 change: 1 addition & 0 deletions database/sql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CREATE DATABASE IF NOT EXISTS `wordpress_unit_tests`;
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'localhost' IDENTIFIED BY 'wp';
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'192.168.50.1' IDENTIFIED BY 'wp';
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'192.168.56.1' IDENTIFIED BY 'wp';

# Create an external user with privileges on all databases in mysql so
# that a connection can be made from the local machine without an SSH tunnel
Expand Down
17 changes: 6 additions & 11 deletions provision/core/env/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,52 +67,45 @@ function cleanup_terminal_splash() {
# @description Sets up the VVV users bash profile, and configuration files
# @noargs
function profile_setup() {
vvv_info " * Setting ownership of files in /home/vagrant to vagrant"
chown -R vagrant:vagrant /home/vagrant/

# Copy custom dotfiles and bin file for the vagrant user from local
vvv_info " * Copying /srv/provision/core/env/homedir/.bash_profile to /home/vagrant/.bash_profile"
rm -f "/home/vagrant/.bash_profile"
noroot cp -f "/srv/provision/core/env/homedir/.bash_profile" "/home/vagrant/.bash_profile"

vvv_info " * Copying /srv/provision/core/env/homedir/.bash_aliases to /home/vagrant/.bash_aliases"
rm -f "/home/vagrant/.bash_aliases"
noroot cp -f "/srv/provision/core/env/homedir/.bash_aliases" "/home/vagrant/.bash_aliases"

vvv_info " * Copying /srv/provision/core/env/homedir/.bash_aliases to ${HOME}/.bash_aliases"
rm -f "${HOME}/.bash_aliases"
cp -f "/srv/provision/core/env/homedir/.bash_aliases" "${HOME}/.bash_aliases"

vvv_info " * Copying /srv/provision/core/env/homedir/.vimrc to /home/vagrant/.vimrc"
rm -f "/home/vagrant/.vimrc"
noroot cp -f "/srv/provision/core/env/homedir/.vimrc" "/home/vagrant/.vimrc"

if [[ ! -d "/home/vagrant/.subversion" ]]; then
noroot mkdir -p "/home/vagrant/.subversion"
fi

vvv_info " * Copying /srv/provision/core/env/homedir/.subversion/subversion-servers to /home/vagrant/.subversion/servers"
rm -f /home/vagrant/.subversion/servers
noroot cp "/srv/provision/core/env/homedir/.subversion/subversion-servers" "/home/vagrant/.subversion/servers"

vvv_info " * Copying /srv/provision/core/env/homedir/.subversion/subversion-config to /home/vagrant/.subversion/config"
rm -f /home/vagrant/.subversion/config
noroot cp "/srv/provision/core/env/homedir/.subversion/subversion-config" "/home/vagrant/.subversion/config"

# If a bash_prompt file exists in the VVV config/ directory, copy to the VM.
if [[ -f "/srv/config/bash_prompt" ]]; then
vvv_info " * Copying /srv/config/bash_prompt to /home/vagrant/.bash_prompt"
rm -f /home/vagrant/.bash_prompt
noroot cp "/srv/config/bash_prompt" "/home/vagrant/.bash_prompt"
fi

if [ -d "/etc/ssh" ]; then
vvv_info " * Copying /srv/provision/core/env/ssh/ssh_known_hosts to /etc/ssh/ssh_known_hosts"
cp -f /srv/provision/core/env/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts
vvv_info " * Copying /srv/provision/core/env/ssh/sshd_config to /etc/ssh/sshd_config"
cp -f /srv/provision/core/env/ssh/sshd_config /etc/ssh/sshd_config
vvv_info " * Reloading SSH Daemon"
service ssh reload
if ! sudo service ssh reload; then
vvv_error " ! SSH daemon failed to reload"
return 1
fi
fi
}

Expand All @@ -126,4 +119,6 @@ function vvv_init_profile() {
profile_setup
}

export -f vvv_init_profile;

vvv_add_hook init vvv_init_profile 0
1 change: 1 addition & 0 deletions provision/core/mailhog/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function mailhog_restart() {
service mailhog restart
fi
}
export -f mailhog_restart

vvv_add_hook services_restart mailhog_restart

Expand Down
Loading

0 comments on commit 5b3aa20

Please sign in to comment.