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
|
||||||
|
|
||||||
#### wordpress_cron
|
#### 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.
|
* 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.
|
* 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 file **${WP_ROOT}/.update** exists !
|
* So, be sure to monitore if the files **${WP_ROOT}/.update_*** exists !
|
||||||
|
|
||||||
[wordpress website]: https://wordpress.org/
|
[wordpress website]: https://wordpress.org/
|
||||||
[wp-clie website]: https://make.wordpress.org/cli/handbook/installing/
|
[wp-clie website]: https://make.wordpress.org/cli/handbook/installing/
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
# This script do the following :
|
# This script do the following :
|
||||||
# Use wp-cli (https://make.wordpress.org/cli/handbook/installing/)
|
# 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.
|
# Verify if an update is available for WordPress plugins.
|
||||||
# Create a file you need to monitore.
|
# Create a file you need to monitore.
|
||||||
|
|
||||||
WP_ROOT="/var/www/wordpress"
|
WP_ROOT="/var/www/wordpress"
|
||||||
WP_CLI_PATH="/usr/local/bin/wp"
|
WP_CLI_PATH="/usr/local/bin/wp"
|
||||||
|
WP_CORE_UPDATE_LOG="${WP_ROOT}/.update_core"
|
||||||
WP_PLUGIN_UPDATE_LOG="${WP_ROOT}/.update_plugin"
|
WP_PLUGIN_UPDATE_LOG="${WP_ROOT}/.update_plugin"
|
||||||
|
|
||||||
if [ ! -d "${WP_ROOT}" ]; then
|
if [ ! -d "${WP_ROOT}" ]; then
|
||||||
|
@ -19,14 +22,24 @@ if [ ! -f "${WP_CLI_PATH}" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# Verify if updates are availables for plugins
|
||||||
if sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" plugin list|grep -q -- "available"
|
if sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" plugin list|grep -q -- "available"
|
||||||
then
|
then
|
||||||
touch "${WP_PLUGIN_UPDATE_LOG}"
|
touch "${WP_PLUGIN_UPDATE_LOG}"
|
||||||
printf '%b' "Please upgrade\n"
|
#printf '%b' "Please upgrade plugins\n"
|
||||||
else
|
else
|
||||||
rm -f "${WP_PLUGIN_UPDATE_LOG}"
|
rm -f "${WP_PLUGIN_UPDATE_LOG}"
|
||||||
printf '%b' "Nothing to do\n"
|
#printf '%b' "Nothing to do\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue