Last active
March 8, 2017 15:22
-
-
Save matt40k/8efec92c6568a4f363be595568366970 to your computer and use it in GitHub Desktop.
Updates WordPress on Mythic Beasts's shell web hosting using WP-CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# m h dom mon dow command | |
*/15 * * * * /home/$USER/wp_update.sh >/home/$USER/logs/wplog.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir logs | |
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
wget https://gist.githubusercontent.com/matt40k/8efec92c6568a4f363be595568366970/raw/wp_update.sh | |
chmod +x wp_update.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Updates all WordPress instances on your shell web hosting | |
# using WP-CLI | |
# | |
WWWPATH="/home/$USER/www" | |
for DOMAINPATH in "`find $WWWPATH -name wp-config.php -printf '%h\n'`"; do | |
DOMAIN=${DOMAINPATH:${#WWWPATH}+1} | |
echo -n `date +%d/%m/%Y\ %H:%M:%S`; | |
echo -n " - "; | |
echo "Updating WordPress for $DOMAIN"; | |
# Update WordPress | |
# - Core | |
php wp-cli.phar core update --path=$WWWPATH/$DOMAIN/ | |
php wp-cli.phar core update-db --path=$WWWPATH/$DOMAIN/ | |
# - Plugins | |
php wp-cli.phar plugin update --all --path=$WWWPATH/$DOMAIN/ | |
# - Themes | |
php wp-cli.phar theme update --all --path=$WWWPATH/$DOMAIN/ | |
# - Translations | |
php wp-cli.phar core language update --path=$WWWPATH/$DOMAIN/ | |
# Maintenance | |
php wp-cli.phar db check --path=$WWWPATH/$DOMAIN/ | |
php wp-cli.phar db optimize --path=$WWWPATH/$DOMAIN/ | |
echo -n `date +%d/%m/%Y\ %H:%M:%S`; | |
echo -n " - "; | |
echo "Update WordPress complete for $DOMAIN"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment