Skip to content

Instantly share code, notes, and snippets.

@lukapaunovic lukapaunovic/wp-update.sh
Last active Aug 25, 2018

Embed
What would you like to do?
Mass update WP core, themes & plugins - cPanel servers
#!/bin/bash
# Script will not be updating themes. If you want to update themes uncomment last two lines
#Get latest WP-CLI
rm -rf /home/wp
wget --quiet https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /home/wp
chmod +x /home/wp
sleep 2
#Color play
Yellow='\e[93m\e[1m'
Green='\e[92m\e[1m'
Red='\e[91m\e[1m'
Color_Off='\033[0m'
# You can set /opt/cpanel/ea-php56/root/usr/bin/php
# here to avoid compatibility problems in MultiPHP environments.
PHP_PATH="/usr/local/bin/php"
# Start updating
echo -e "$Yellow Updating WP core $Color_Off";
for i in `ls --hide='system' /var/cpanel/users/`; do sudo -H -u $i cp /home/wp /home/$i/wp && sudo -H -u $i find /home/$i/public_html -name 'wp-admin' -execdir $PHP_PATH /home/$i/wp core update \; && sudo -H -u $i rm -rf /home/$i/wp ; done
echo -e "$Green Updating plugins $Color_Off";
for i in `ls --hide='system' /var/cpanel/users/`; do sudo -H -u $i cp /home/wp /home/$i/wp && sudo -H -u $i find /home/$i/public_html -name 'wp-admin' -execdir $PHP_PATH /home/$i/wp plugin update-all \; && sudo -H -u $i rm -rf /home/$i/wp ; done
#echo -e "$Red Updating themes $Color_Off";
#for i in `ls --hide='system' /var/cpanel/users/`; do sudo -H -u $i cp /home/wp /home/$i/wp && sudo -H -u $i find /home/$i/public_html -name 'wp-admin' -execdir $PHP_PATH /home/$i/wp theme update-all \; && sudo -H -u $i rm -rf /home/$i/wp ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.