Last active
August 25, 2018 22:02
-
-
Save lukapaunovic/49a417de96f7abbc57b6048e0e102786 to your computer and use it in GitHub Desktop.
Mass update WP core, themes & plugins - cPanel servers
This file contains 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 | |
# 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