Correct the tests.

This commit is contained in:
Jeremy Gardais 2017-02-15 14:50:07 +01:00
parent a9cd46082e
commit 8fe485446d
1 changed files with 9 additions and 10 deletions

View File

@ -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