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