Add wordpress_cron to monitore WordPress plugin's update.

This commit is contained in:
Jeremy Gardais 2017-02-15 12:16:46 +01:00
parent 58d069443d
commit 2928251d4a
2 changed files with 46 additions and 2 deletions

View File

@ -7,6 +7,7 @@
* [Proxmox](#proxmox) * [Proxmox](#proxmox)
* [Grav](#grav) * [Grav](#grav)
* [Sesame2mail](#sesame2mail) * [Sesame2mail](#sesame2mail)
* [WordPress](#wordpress)
## Overview ## Overview
@ -30,7 +31,6 @@ This script must be used as a vzdump's hook (the backup utility for CT and VMs f
3. Customization: 3. Customization:
* If you don't store template in the default path (**/mnt/zfsbkp/template/cache**), please edit the variable **$TEMPLATE_DIR** in the script. * If you don't store template in the default path (**/mnt/zfsbkp/template/cache**), please edit the variable **$TEMPLATE_DIR** in the script.
### Grav ### Grav
#### grav_cron #### grav_cron
@ -39,7 +39,6 @@ A daily cron to check if [Grav][grav website] got available updates.
* If an update is available, it will create a empty file (${GRAV_ROOT}/logs/update), else it will ensure the "update" file is removed. * If an update is available, it will create a empty file (${GRAV_ROOT}/logs/update), else it will ensure the "update" file is removed.
* Be sure to monitore if **${GRAV_ROOT}/logs/update** exist. * Be sure to monitore if **${GRAV_ROOT}/logs/update** exist.
[grav website]: https://getgrav.org/ [grav website]: https://getgrav.org/
### Sesame2mail ### Sesame2mail
@ -49,3 +48,15 @@ Give a user's mail address from it's user ID (sesame).
The first argument can be: The first argument can be:
* A file with a list of user ID (sesame), one per line. * A file with a list of user ID (sesame), one per line.
* A user ID (sesame), only one. * A user ID (sesame), only one.
### WordPress
#### wordpress_cron
A daily cron to check [WordPress][wordpress website]'s plugins got available update.
* 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!
[wordpress website]: https://wordpress.org/
[wp-clie website]: https://make.wordpress.org/cli/handbook/installing/

33
wordpress_cron Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
# This script do the following:
# Use wp-cli (https://make.wordpress.org/cli/handbook/installing/)
# 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_UPDATE_LOG="${WP_ROOT}/.update"
if [ ! -d "${WP_ROOT}" ]; then
printf '%b' "${WP_ROOT} does not seem to be a WordPress install.\n"
exit 1
fi
if [ ! -d "${WP_CLI_PATH}" ]; then
printf '%b' "${WP_CLI_PATH} does not seem to be available.\n"
exit 1
fi
WP_UPDATE=$(sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" plugin list|grep available)
# Verify if the variable contains something
if [ -z "${WP_UPDATE}" ]; then
#rm -f "${WP_UPDATE_LOG}"
printf '%b' "Nothing to do\n"
else
#touch "${WP_UPDATE_LOG}"
printf '%b' "Please upgrade\n"
fi
exit 0