Skip to content

Commit

Permalink
Merge pull request #2630 from Varying-Vagrant-Vagrants/more-docker-co…
Browse files Browse the repository at this point in the history
…mpatibility-tweaks

More docker compatibility tweaks
  • Loading branch information
tomjn authored Sep 10, 2022
2 parents b14d33a + 0fd2c95 commit af45073
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
19 changes: 12 additions & 7 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -407,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 @@ -437,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
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
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
4 changes: 4 additions & 0 deletions provision/core/mariadb/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ function mysql_setup() {
chmod 0644 "/home/vagrant/.my.cnf"
vvv_info " * Copied /srv/provision/core/mariadb/config/root-my.cnf to /home/vagrant/.my.cnf"

# Due to systemd dependencies, in docker, mysql service is not auto started
vvv_info " * Ensuring MariaDB service is started"
service mariadb restart

if [ "${VVV_DOCKER}" != 1 ]; then
check_mysql_root_password
fi
Expand Down
39 changes: 38 additions & 1 deletion provision/provision-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ vvv_hook() {
}
export -f vvv_hook


# @description Necessary for vvv_parallel_hook, do not use.
# @internal
function vvv_run_parallel_hook_function() {
eval $1

Expand Down Expand Up @@ -448,6 +449,7 @@ function vvv_parallel_hook() {
}
export -f vvv_parallel_hook

# @description Updates Apt keys then fetches Apt updates.
vvv_apt_update() {
vvv_info " * Updating apt keys"
apt-key update -y
Expand All @@ -458,6 +460,7 @@ vvv_apt_update() {
apt-get update -y --fix-missing
}

# @description Upgrades all Apt packages.
vvv_apt_packages_upgrade() {
vvv_info " * Upgrading apt packages"
vvv_apt_update
Expand All @@ -470,6 +473,7 @@ vvv_apt_packages_upgrade() {
}
export -f vvv_apt_packages_upgrade

# @description Performs Apt autoremoval and cleanup.
vvv_apt_cleanup() {
# Remove unnecessary packages
vvv_info " * Removing unnecessary apt packages..."
Expand Down Expand Up @@ -626,3 +630,36 @@ function vvv_maybe_install_nginx_config() {
}

export -f vvv_maybe_install_nginx_config;

# @description Retrieves a list of sites.
# @noargs
function vvv_get_sites() {
local sites=$(shyaml -q keys "sites" <${VVV_CONFIG})
echo "${sites}"
}

# @description Updates the guest environments hosts file.
# @noargs
function vvv_update_guest_hosts() {
if test -f "/tmp/site-hosts"; then
sudo rm /tmp/site-hosts
fi
local SITES=$(vvv_get_sites)
for SITE in $SITES; do
SITE_ESCAPED="${SITE//./\\.}"
VVV_SITE_NAME=${SITE}
local value=$(shyaml -q get-values "sites.${SITE_ESCAPED}.hosts" <${VVV_CONFIG})
for v in $value; do
echo "127.0.0.1 ${v:-"${VVV_SITE_NAME}.test"}" >> /tmp/site-hosts
done
done

echo "$(</tmp/site-hosts)" | sudo tee -a /etc/hosts > /dev/null

# cleanup
if test -f "/tmp/site-hosts"; then
sudo rm /tmp/site-hosts
fi
}

export -f vvv_update_guest_hosts

0 comments on commit af45073

Please sign in to comment.