Last active
December 13, 2017 14:45
-
-
Save laacz/f928f136dc417adb2543bcbcb8774d56 to your computer and use it in GitHub Desktop.
Find ordpresses and update them (plugins too)
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
#!/usr/bin/env bash | |
# | |
# Script will find all wordpress installs and check if they're out of date | |
# | |
# Using wp-cli - http://wp-cli.org/ | |
# Paths to search for wordpresses. Separated by space. | |
PATHS="/var/www /data/www" | |
# Paths to ignore (should not be checked). Separated by space. | |
IGNOREPATHS="/data/www/site1 /data/www/site2 " | |
WPCLI=/usr/local/bin/wp-cli | |
WORDPRESSES=$(find $PATHS -type d -name "wp-includes" -print) | |
# Loop through results | |
for WPATH in $WORDPRESSES; do | |
#echo $WPATH | |
# Strip wp-includes from path | |
WPATH=$(dirname $WPATH) | |
# If folder is excluded, continue | |
if [ "${IGNOREPATHS/$WPATH}" != "$IGNOREPATHS" ]; then | |
continue; | |
fi | |
$WPCLI --quiet --allow-root --path=$WPATH core update | |
if [ $? -ne 0 ]; then | |
echo "WHILE DOING $WPATH" | |
fi | |
$WPCLI --quiet --allow-root --path=$WPATH plugin --all update | |
if [ $? -ne 0 ]; then | |
echo "WHILE DOING $WPATH" | |
fi | |
if [ -f "$WPATH/.preserve-owner" ] ; then | |
OWNER=$(stat -c "%U:%G" $WPATH/.preserve-owner) | |
echo "Preserving owner $OWNER on $WPATH" | |
chown -R $OWNER $WPATH/wp-content/plugins $WPATH/wp-admin $WPATH/wp-includes $WPATH/index.php $WPATH/xmlrpc.php $WPATH/wp*.php | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment