Also check update for WordPress core.
This commit is contained in:
parent
8fe485446d
commit
f58238e993
|
@ -52,10 +52,10 @@ The first argument can be :
|
|||
### WordPress
|
||||
|
||||
#### wordpress_cron
|
||||
A daily cron to check [WordPress][wordpress website]'s plugins got available update.
|
||||
A daily cron to check [WordPress][wordpress website]'s Core and plugins updates.
|
||||
* It need [**wp-cli**][wp-cli website] tool.
|
||||
* If an update is available, it will create a empty file (${WP_ROOT}/.update), else it will ensure the "update" file is absent.
|
||||
* So, be sure to monitore if the file **${WP_ROOT}/.update** exists !
|
||||
* If an update is available, it will create a empty file (${WP_ROOT}/.update_core or ${WP_ROOT}/.update_plugin), else it will ensure the "update" files are absents.
|
||||
* So, be sure to monitore if the files **${WP_ROOT}/.update_*** exists !
|
||||
|
||||
[wordpress website]: https://wordpress.org/
|
||||
[wp-clie website]: https://make.wordpress.org/cli/handbook/installing/
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
# This script do the following :
|
||||
# Use wp-cli (https://make.wordpress.org/cli/handbook/installing/)
|
||||
# Verify if an update is available for the WordPress core.
|
||||
# Create a file you need to monitore.
|
||||
# Verify if an update is available for WordPress plugins.
|
||||
# Create a file you need to monitore.
|
||||
|
||||
WP_ROOT="/var/www/wordpress"
|
||||
WP_CLI_PATH="/usr/local/bin/wp"
|
||||
WP_CORE_UPDATE_LOG="${WP_ROOT}/.update_core"
|
||||
WP_PLUGIN_UPDATE_LOG="${WP_ROOT}/.update_plugin"
|
||||
|
||||
if [ ! -d "${WP_ROOT}" ]; then
|
||||
|
@ -19,14 +22,24 @@ if [ ! -f "${WP_CLI_PATH}" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Verify if an update is available for WordPress
|
||||
if sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" plugin list|grep -v -i -q -- "success"
|
||||
then
|
||||
touch "${WP_CORE_UPDATE_LOG}"
|
||||
#printf '%b' "Please upgrade WordPress\n"
|
||||
else
|
||||
rm -f "${WP_CORE_UPDATE_LOG}"
|
||||
#printf '%b' "Nothing to do\n"
|
||||
fi
|
||||
|
||||
# Verify if updates are availables for plugins
|
||||
if sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" plugin list|grep -q -- "available"
|
||||
then
|
||||
touch "${WP_PLUGIN_UPDATE_LOG}"
|
||||
printf '%b' "Please upgrade\n"
|
||||
#printf '%b' "Please upgrade plugins\n"
|
||||
else
|
||||
rm -f "${WP_PLUGIN_UPDATE_LOG}"
|
||||
printf '%b' "Nothing to do\n"
|
||||
#printf '%b' "Nothing to do\n"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue