Last active
November 9, 2020 21:03
-
-
Save 01000101/23c08359b9304b415cb5a7227dd3187b to your computer and use it in GitHub Desktop.
Updates all standard WordPress sites hosted on a cPanel server - both core and plugins. Also snoops for WP installs in a root directory (sub-sites).
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 | |
| for i in `/usr/local/cpanel/bin/apitool listaccts --output json | jq -r '.data.acct[] | select(.suspended == 0) | .user'`; do | |
| echo "Updating account: ${i}"; | |
| su -s /bin/bash -c "wp core update --path=/home/${i}/public_html/" $i; | |
| su -s /bin/bash -c "wp plugin update --path=/home/${i}/public_html/ --all" $i; | |
| for subsite in `find /home/${i}/public_html/ -name "wp-config.php" | grep -Po "/home/${i}/public_html/\K.*(?=/wp-config.php)"`; do | |
| echo "Updating sub-site account: ${subsite}"; | |
| su -s /bin/bash -c "wp core update --path=/home/${i}/public_html/${subsite}/" $i; | |
| su -s /bin/bash -c "wp plugin update --path=/home/${i}/public_html/${subsite}/ --all" $i; | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment