From 8fe485446de2d51370525a10e61a19bec1f29000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 15 Feb 2017 14:50:07 +0100 Subject: [PATCH] Correct the tests. --- wordpress_cron | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/wordpress_cron b/wordpress_cron index a6911fc..a90dc1b 100755 --- a/wordpress_cron +++ b/wordpress_cron @@ -7,27 +7,26 @@ WP_ROOT="/var/www/wordpress" WP_CLI_PATH="/usr/local/bin/wp" -WP_UPDATE_LOG="${WP_ROOT}/.update" +WP_PLUGIN_UPDATE_LOG="${WP_ROOT}/.update_plugin" 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 +if [ ! -f "${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}" +# 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" +else + rm -f "${WP_PLUGIN_UPDATE_LOG}" + printf '%b' "Nothing to do\n" fi exit 0