Skip to content

Commit

Permalink
Merge branch 'develop' into modify/auto-pull-git-template-option
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjn authored Sep 20, 2024
2 parents ad91711 + 6e02f3b commit 257ceab
Show file tree
Hide file tree
Showing 22 changed files with 82 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Icon\r\r

# Because this really is a working directory, ignore vagrant's files
/.vagrant
vagrant.log

# This is a file intended for hooking in a custom Vagrant configuration on up
/Customfile
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ permalink: /docs/en-US/changelog/

* Upgraded MariaDB from 10.5 to 10.11 ( #2728 )
* Added a `skip_site_provisioner_update` option to prevent site provisioners being overwritten by updates ( #2733 )
* Only start services that aren't running in post-up scripts ( #2732 )

### Bug Fixes

* VVV will check if Parallels is installed before defaulting to docker on Arm64/Apple Silicon due to issues with Docker detection ( #2722 )
* Switched from Rackspace to Starburst services for MariaDB mirrors ( #2728 )
* Fixes for service starts under some situations in Docker ( #2732 )
* Fixed an issue with trailing slashes and site provisioners introduced in an earlier version (#2731)

### Maintenance

* Removed commented out subversion config lines that were flagged as a false positive security issue ( #2725 )
* Adjusted the domains used in the network check to remove unused domains and add some that are used ( #2734 )

## 3.13.2 ( 2024 July 19th )

Expand Down
12 changes: 6 additions & 6 deletions config/homebin/db_backup
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Create individual SQL files for each database. These files
# are imported automatically during an initial provision if
Expand All @@ -10,7 +10,7 @@ if [ -z "${VVV_LOG+x}" ]; then
export VVV_LOG=""
fi

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

source /srv/provision/provision-helpers.sh

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

vvv_info " * Fetching Database names"
mysql -e 'show databases' | grep -v -F "Database" > $TMPFIFODIR/dbnames &
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;
Expand All @@ -32,7 +32,7 @@ while read db_name; do
[ "${db_name}" == "wordpress_unit_tests" ] && vvv_info " - skipped <b>${db_name}</b>" && continue;

skip="false"
for exclude in ${exclude_list[@]}; do
for exclude in "${exclude_list[@]}"; do
if [ "${exclude}" == "${db_name}" ]; then
skip="true"
fi
Expand All @@ -51,7 +51,7 @@ while read db_name; do
fi
fi
databases+=( "${db_name}" )
done < $TMPFIFODIR/dbnames
done < "${TMPFIFODIR}/dbnames"

ext=".sql"
if [[ "${gzip}" == "True" ]]; then
Expand All @@ -67,7 +67,7 @@ do
else
mysqldump "${db}" > "/srv/database/backups/${db}.sql";
fi
let "count=count+1"
count=$((count+1))
done

vvv_success " * Finished backing up databases to the <b>database/sql/backups</b><success> folder</success>"
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
#!/usr/bin/env bash
#
# Restore individual SQL files for each database.
. /srv/database/import-sql.sh
4 changes: 2 additions & 2 deletions config/homebin/is_utility_installed
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
utilities=$(shyaml get-values "utilities.${1}" 2> /dev/null < "${VVV_CONFIG}")
for utility in ${utilities}; do
if [[ "${utility}" == "${2}" ]]; then
exit 0
exit 0
fi
done
exit 1
2 changes: 1 addition & 1 deletion config/homebin/makepot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
# Convenience script to run makepot.php

php /srv/www/wordpress-develop/tools/i18n/makepot.php $1 $2 $3 $4
2 changes: 1 addition & 1 deletion config/homebin/tideways_off
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

switch_php_debugmod none

2 changes: 1 addition & 1 deletion config/homebin/tideways_on
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

switch_php_debugmod tideways
2 changes: 1 addition & 1 deletion config/homebin/vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ echo -e "${YELLOW} █░░█░░░░░░▄▀ ${CRESET}"
echo -e "${YELLOW}──────────────────────${CRESET}"
echo ""
echo -e "${PURPLE} ! You're still SSH'd into the VVV virtual machine!${CRESET}"
echo -e "${PURPLE} Run exit and try again${CRESET}"
echo -e "${PURPLE} Run exit and try again${CRESET}"
6 changes: 3 additions & 3 deletions config/homebin/vagrant_destroy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This script is run whenever `vagrant destroy` is used to destroy
# the virtual machine. To customize this behavior, include a file
Expand All @@ -18,9 +18,9 @@ else
fi

# Check if backups are turned on or off
run_backups=`cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup.enable`
run_backups=$(cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup.enable)
if [[ -z "$run_backups" ]]; then
run_backups=`cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup`
run_backups=$(cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup)
fi

if [[ $run_backups != "False" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions config/homebin/vagrant_halt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This script is run whenever `vagrant halt` is used to power off
# the virtual machine. To customize this behavior, include a file
Expand All @@ -18,9 +18,9 @@ else
fi

# Check if backups are turned on or off
run_backups=`cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup.enable`
run_backups=$(cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup.enable)
if [[ -z "$run_backups" ]]; then
run_backups=`cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup`
run_backups=$(cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup)
fi

if [[ $run_backups != "False" ]]; then
Expand Down
14 changes: 11 additions & 3 deletions config/homebin/vagrant_provision
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This script is run after a provision. To customize this behavior,
# include a file in your local VVV/config/homebin
Expand All @@ -22,10 +22,18 @@ if [[ -f /srv/config/homebin/vagrant_provision_custom ]]; then
fi

vvv_info " * Restarting Nginx service"
sudo service nginx restart
if sudo service nginx status > /dev/null; then
sudo service nginx restart
else
sudo service nginx start
fi

vvv_info " * Restarting MariaDB service"
sudo service mariadb restart
if sudo service mariadb status > /dev/null; then
sudo service mariadb restart
else
sudo service mariadb start
fi

if [ ! -f /.dockerenv ]; then
if [ -x "$(command -v ntpdate)" ]; then
Expand Down
8 changes: 4 additions & 4 deletions config/homebin/vagrant_suspend
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This script is run whenever `vagrant suspend` is used to suspend
# the virtual machine. To customize this behavior, include a file
Expand All @@ -18,13 +18,13 @@ else
fi

# Check if backups are turned on or off
run_backups=`cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup.enable`
run_backups=$(cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup.enable)
if [[ -z "$run_backups" ]]; then
run_backups=`cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup`
run_backups=$(cat ${VVV_CONFIG} | shyaml -q get-value general.db_backup)
fi

if [[ $run_backups != "False" ]]; then
/srv/config/homebin/db_backup
/srv/config/homebin/db_backup
fi

RED="\033[38;5;9m"
Expand Down
29 changes: 18 additions & 11 deletions config/homebin/vagrant_up
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This script is run whenever `vagrant up` is used to power on
# the virtual machine. To customize this behavior, include a file
Expand All @@ -25,23 +25,30 @@ URL="\033[4;38;5;3m"
if [[ -f /srv/config/homebin/vagrant_up_custom ]]; then
vvv_info " * Custom vagrant up script found, executing vagrant_up_custom"
/srv/config/homebin/vagrant_up_custom
vvv_info " * Custom vagrant up script finished"
fi

# /etc/host doesn't survive restart on docker
vvv_info " * Reinit /etc/hosts"
vvv_info " * Updatin Guest VM /etc/hosts"
vvv_update_guest_hosts

vvv_info " * Restarting Nginx"
sudo service nginx restart
if ! sudo service nginx status > /dev/null; then
vvv_info " * Starting Nginx service"
sudo service nginx start
fi

vvv_info " * Restarting MariaDB"
sudo service mariadb restart
if ! sudo service mariadb status > /dev/null; then
vvv_info " * Starting MariaDB service"
sudo service mariadb start
fi

vvv_info " * Restarting PHP-FPM"
find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;
vvv_info " * Checking PHP-FPM Services"
find /etc/init.d/ -name "php*-fpm" -exec bash -c 'if ! sudo service "$(basename "$0")" status > /dev/null; then sudo service "$(basename "$0")" start; fi' {} \;

vvv_info " * Restarting Memcache"
sudo service memcached restart
if ! sudo service memcached status > /dev/null; then
vvv_info " * Starting memcached service"
sudo service memcached start
fi

vvv_info " * Restarting Mailhog"
/usr/bin/env /usr/local/bin/mailhog > /dev/null 2>&1 &
Expand All @@ -50,7 +57,7 @@ if [ ! -f /.dockerenv ]; then
if [ -x "$(command -v ntpdate)" ]; then
vvv_info " * Syncing clocks"
if sudo ntpdate -u ntp.ubuntu.com; then
vvv_info " * clocks synced"
vvv_succss " * clocks synced"
else
vvv_warn " - clock synchronisation failed"
fi
Expand Down
2 changes: 1 addition & 1 deletion config/homebin/xdebug_off
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

switch_php_debugmod none
2 changes: 1 addition & 1 deletion config/homebin/xdebug_on
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

switch_php_debugmod xdebug
10 changes: 5 additions & 5 deletions provision/core/mariadb/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ function mysql_setup() {

# Due to systemd dependencies, in docker, mysql service is not auto started
vvv_info " * Ensuring MariaDB service is started"
service mariadb restart
service mariadb status > /dev/null || service mariadb start

if [ "${VVV_DOCKER}" != 1 ]; then
if [ ! -f /.dockerenv ]; then
check_mysql_root_password
fi

# MySQL gives us an error if we restart a non running service, which
# happens after a `vagrant halt`. Check to see if it's running before
# deciding whether to start or restart.
if [ $(service mariadb status|grep 'Uptime' | wc -l) -ne 1 ]; then
if service mariadb status > /dev/null; then
vvv_info " * Starting the mariadb service"
service mariadb start
service mariadb restart
else
vvv_info " * Restarting mariadb service"
service mariadb restart
service mariadb start
fi

# IMPORT SQL
Expand Down
4 changes: 3 additions & 1 deletion provision/core/memcached/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export -f vvv_memcached_setup
vvv_add_hook after_packages vvv_memcached_setup 60

function vvv_memcached_restart() {
if [ "${VVV_DOCKER}" != 1 ]; then
if service memcached status > /dev/null; then
service memcached restart
else
service memcached start
fi
}

Expand Down
4 changes: 3 additions & 1 deletion provision/core/nginx/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ export -f nginx_setup
vvv_add_hook after_packages nginx_setup 40

function vvv_nginx_restart() {
if [ "${VVV_DOCKER}" != 1 ]; then
if service nginx status > /dev/null; then
service nginx restart
else
service nginx start
fi
}

Expand Down
2 changes: 1 addition & 1 deletion provision/core/php/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ vvv_add_hook finalize phpfpm_finalize

function phpfpm_services_restart() {
# Restart all php-fpm versions
if [ "${VVV_DOCKER}" != 1 ]; then
if [ ! -f /.dockerenv ]; then
find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;
fi
}
Expand Down
2 changes: 1 addition & 1 deletion provision/core/vvv/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export -f shyaml_setup
vvv_add_hook after_packages shyaml_setup 0

function vvv_ntp_restart() {
if [ "${VVV_DOCKER}" != 1 ]; then
if [ ! -f /.dockerenv ]; then
service ntp restart
fi
}
Expand Down
17 changes: 11 additions & 6 deletions provision/provision-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# @description This file is for common helper functions that
# get called in other provisioners

Expand All @@ -19,7 +19,6 @@ export BLUE="\033[0;38;5;4m" # 33m"
export PURPLE="\033[0;38;5;5m" # 129m"
export CRESET="\033[0m"


VVV_CONFIG=/vagrant/vvv-custom.yml
if [[ -f /vagrant/config.yml ]]; then
VVV_CONFIG=/vagrant/config.yml
Expand Down Expand Up @@ -67,7 +66,7 @@ export -f network_detection
# @exitcode 1 If network issues are found
function check_network_connection_to_host() {
local url=${1:-"http://ppa.launchpadcontent.net"}
vvv_info " * Testing network connection to <url>${url}</url> with wget -q --spider --timeout=5 --tries=3 ${url}"
vvv_info " * Testing network connection to <url>${url}</url><info> with wget -q --spider --timeout=5 --tries=3 ${url}"

# Network Detection
#
Expand Down Expand Up @@ -101,8 +100,10 @@ function network_check() {
"https://github.com" # needed for dashboard, extensions, etc
"https://raw.githubusercontent.com" # some scripts and provisioners rely on this
"https://getcomposer.org" # composer is used for lots of sites and provisioners
"https://deb.nodesource.com" # Node JS installation
"https://mirror.rackspace.com" # MariaDB mirror
"https://packagist.org" # Composer Packages
"https://mariadb.gb.ssimn.org" # MariaDB mirror
"http://ports.ubuntu.com/"
"https://nginx.org/packages/mainline/"
)
declare -a failed_hosts=()
for url in "${hosts_to_test[@]}"; do
Expand Down Expand Up @@ -636,7 +637,11 @@ function vvv_maybe_install_nginx_config() {
return 1
fi

sudo service nginx reload
if sudo service nginx status > /dev/null; then
sudo service nginx reload
else
sudo service nginx start
fi

return 0
}
Expand Down

0 comments on commit 257ceab

Please sign in to comment.