From e26f9d54da8b11af971a71d717a68a86b6926580 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Wed, 26 May 2021 13:10:56 +0100 Subject: [PATCH] WordPress.org: fix #153 - cavalcade provisioning failures Refactors cavalcade provisioning to: - remove duplication - handle when the service fails to restart - better handle folder creation - avoid potential permission issues for some files - prevent parameter expansion on the changed lines that could cause sites with spaces in their folder names to fail --- wordpressorg.test/provision/vvv-init.sh | 47 ++++++++++++++----------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/wordpressorg.test/provision/vvv-init.sh b/wordpressorg.test/provision/vvv-init.sh index 05c3dd6f2..31801c154 100644 --- a/wordpressorg.test/provision/vvv-init.sh +++ b/wordpressorg.test/provision/vvv-init.sh @@ -19,6 +19,30 @@ WP_LOCALES=( ja es_ES ) wme_svn_git_migration $SITE_DIR +function wme_wporg_setup_cavalcade() { + # Cavalcade + printf "Installing Cavalcade..." + wme_noroot git clone https://github.com/humanmade/Cavalcade.git "${SITE_DIR}/wp-content/mu-plugins/cavalcade" + wme_noroot cp -f "${PROVISION_DIR}/cavalcade.php" "${SITE_DIR}/wp-content/mu-plugins/" + + if [[ -d "/etc/cavalcade" ]]; then + pushd "/etc/cavalcade" + git pull + popd + else + mkdir -p "/etc/cavalcade" + git clone https://github.com/humanmade/Cavalcade-Runner.git "/etc/cavalcade" + fi + + mkdir -p "/etc/init/" + cp -f "${PROVISION_DIR}/cavalcade-wordpressorg.conf" "/etc/init/cavalcade-wordpressorg.conf" + if service cavalcade-wordpressorg restart; then + printf "cavalcade service restarted" + else + printf "cavalcade service did not restart" + fi +} + if [ ! -L $SITE_DIR ]; then printf "\n#\n# Provisioning $SITE_DOMAIN\n#\n" @@ -82,20 +106,7 @@ if [ ! -L $SITE_DIR ]; then wme_download_pomo "${gplocale}" "meta/o2" "$SITE_DIR/wp-content/languages/themes/o2-${locale}" done - # Cavalcade - printf "Installing Cavalcade..." - git clone https://github.com/humanmade/Cavalcade.git $SITE_DIR/wp-content/mu-plugins/cavalcade - cp -f $PROVISION_DIR/cavalcade.php $SITE_DIR/wp-content/mu-plugins/ - - if [[ ! -d "/etc/cavalcade" ]]; then - git clone https://github.com/humanmade/Cavalcade-Runner.git /etc/cavalcade - else - git -C /etc/cavalcade pull - fi - - mkdir -p "/etc/init/" - cp -f "$PROVISION_DIR/cavalcade-wordpressorg.conf" "/etc/init/cavalcade-wordpressorg.conf" - service cavalcade-wordpressorg restart + wme_wporg_setup_cavalcade # Ignore external dependencies and Meta Environment tweaks IGNORED_FILES=( @@ -151,13 +162,7 @@ else # translate.wordpressorg.test git -C $SITE_DIR/wp-content/plugins/glotpress pull - # Cavalcade - git -C $SITE_DIR/wp-content/mu-plugins/cavalcade pull - git -C /etc/cavalcade pull - cp -f "$PROVISION_DIR/cavalcade.php" "$SITE_DIR/wp-content/mu-plugins/" - mkdir -p "/etc/init" - cp -f "$PROVISION_DIR/cavalcade-wordpressorg.conf" "/etc/init/cavalcade-wordpressorg.conf" - service cavalcade-wordpressorg restart + wme_wporg_setup_cavalcade fi # Pull global header/footer