Skip to content

Instantly share code, notes, and snippets.

@shoreline-chrism
Created December 18, 2020 16:20
Show Gist options
  • Save shoreline-chrism/2f54f1bc6a49a7dff2dd84fc146622fb to your computer and use it in GitHub Desktop.
Save shoreline-chrism/2f54f1bc6a49a7dff2dd84fc146622fb to your computer and use it in GitHub Desktop.
Update plugin on WPE install
#!/bin/bash
# To update multiple installs, sepearate the install names by spaces when prompted
read -p "WPE Install Name(s) (separate by spaces): " WPE_INSTALL
# Convert to array
WPE_INSTALL=( $WPE_INSTALL )
read -p "Plugin slug (ie: contact-form-7): " PLUGIN_SLUG
for element in "${WPE_INSTALL[@]}"
do
TARGET_PATH="~/sites/$element"
# Backup db on WPE install
echo -e "Backing up the database on the website as /wp-content/$PLUGIN_SLUG-backup.sql"
wp db export --ssh="$element@$element.ssh.wpengine.net$TARGET_PATH/wp-content/" "$PLUGIN_SLUG-backup.sql"
# Update Plugin
echo -e "Updating plugin $PLUGIN_SLUG on $element"
wp plugin update "$PLUGIN_SLUG" --ssh="$element@$element.ssh.wpengine.net$TARGET_PATH/wp-content/"
# Clear the cache on WPE
echo -e "Clearing the WPE cache"
wp cache flush --ssh="$element@$element.ssh.wpengine.net$TARGET_PATH/wp-content/"
echo -e "\e[92m$PLUGIN_SLUG update complete.\e[0m"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment