From 2928251d4a0096e759f1eff747fd44a71d7e0313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 15 Feb 2017 12:16:46 +0100 Subject: [PATCH] Add wordpress_cron to monitore WordPress plugin's update. --- README.md | 15 +++++++++++++-- wordpress_cron | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 wordpress_cron diff --git a/README.md b/README.md index eb46d16..7822977 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ * [Proxmox](#proxmox) * [Grav](#grav) * [Sesame2mail](#sesame2mail) + * [WordPress](#wordpress) ## 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 : * 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_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. * Be sure to monitore if **${GRAV_ROOT}/logs/update** exist. - [grav website]: https://getgrav.org/ ### Sesame2mail @@ -49,3 +48,15 @@ Give a user's mail address from it's user ID (sesame). The first argument can be : * A file with a list of user ID (sesame), one per line. * 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/ + diff --git a/wordpress_cron b/wordpress_cron new file mode 100755 index 0000000..a6911fc --- /dev/null +++ b/wordpress_cron @@ -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