Skip to content

Instantly share code, notes, and snippets.

@kiki67100
Created February 10, 2017 10:03
Show Gist options
  • Save kiki67100/a08485536ca97c7f798fd9f4e041b806 to your computer and use it in GitHub Desktop.
Save kiki67100/a08485536ca97c7f798fd9f4e041b806 to your computer and use it in GitHub Desktop.
Upgrade WordPress from wp-cli
#!/bin/bash
cd /data/www/vhosts || exit;
wp cli update --yes >> /root/cron/log-wp.txt
find . -type f -name 'wp-config.php'|while read line;
do
realpath=$(readlink -f $line);
dirname=$(dirname $realpath)
uid=$(stat -c '%U' "$line")
echo "" >> /root/cron/log-wp.txt
echo "-----------$dirname-------" >> /root/cron/log-wp.txt
echo "" >> /root/cron/log-wp.txt
sudo -S -u $uid bash -c "wp --allow-root --path=$dirname --no-color plugin upgrade --all" >> /root/cron/log-wp.txt
sudo -S -u $uid bash -c "wp --allow-root --path=$dirname --no-color core update" >> /root/cron/log-wp.txt
sudo -S -u $uid bash -c "wp --allow-root --path=$dirname --no-color core update-db" >> /root/cron/log-wp.txt
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment