Skip to content

Instantly share code, notes, and snippets.

@lukapaunovic
Last active August 25, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukapaunovic/49a417de96f7abbc57b6048e0e102786 to your computer and use it in GitHub Desktop.
Save lukapaunovic/49a417de96f7abbc57b6048e0e102786 to your computer and use it in GitHub Desktop.
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