Skip to content

Instantly share code, notes, and snippets.

@amityweb
Last active March 15, 2024 08:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amityweb/444c8268d663d3cb3fd219136270ecf3 to your computer and use it in GitHub Desktop.
Save amityweb/444c8268d663d3cb3fd219136270ecf3 to your computer and use it in GitHub Desktop.
Bash script to iterate through all Wordpress sites on RunCloud and update the core, plugins and themes
#!/bin/bash
# Change directory to /home
cd /home
# Iterate through all users directories
for user in * ; do
# For every webapp under the user directory
# Count wp-config files to make sure its Wordpess
# If its Wordpress, then run the WP CLI Script, which calls wp-cron.php
for d in $user/webapps/* ; do
count_file=`ls -1 $d/wp-config.php 2>/dev/null | wc -l`
if [ "$count_file" != "0" ]
then
sudo -u $user -i -- wp core update --path=/home/$d
sudo -u $user -i -- wp plugin update --all --path=/home/$d
sudo -u $user -i -- wp language core update --path=/home/$d
sudo -u $user -i -- wp theme update --all --path=/home/$d
sudo -u $user -i -- wp redis update-dropin --path=/home/$d
sudo -u $user -i -- wp cli cache clear --path=/home/$d
fi
done
done
@amityweb
Copy link
Author

Run file by calling:
sh update_all_wp_sites.sh

@amityweb
Copy link
Author

For testing, change:
for user in * ; do
to a single user directory you dont mind testing on:
for user in mytestsite ; do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment