2017-02-15 12:16:46 +01:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# This script do the following :
|
|
|
|
|
# Use wp-cli (https://make.wordpress.org/cli/handbook/installing/)
|
2017-02-15 15:02:03 +01:00
|
|
|
|
# Verify if an update is available for the WordPress core.
|
|
|
|
|
# Create a file you need to monitore.
|
2017-02-15 12:16:46 +01:00
|
|
|
|
# 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"
|
2017-02-15 15:02:03 +01:00
|
|
|
|
WP_CORE_UPDATE_LOG="${WP_ROOT}/.update_core"
|
2017-02-15 14:50:07 +01:00
|
|
|
|
WP_PLUGIN_UPDATE_LOG="${WP_ROOT}/.update_plugin"
|
2017-02-15 12:16:46 +01:00
|
|
|
|
|
|
|
|
|
if [ ! -d "${WP_ROOT}" ]; then
|
|
|
|
|
printf '%b' "${WP_ROOT} does not seem to be a WordPress install.\n"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-15 14:50:07 +01:00
|
|
|
|
if [ ! -f "${WP_CLI_PATH}" ]; then
|
2017-02-15 12:16:46 +01:00
|
|
|
|
printf '%b' "${WP_CLI_PATH} does not seem to be available.\n"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-15 15:02:03 +01:00
|
|
|
|
# Verify if an update is available for WordPress
|
2017-02-15 16:11:56 +01:00
|
|
|
|
if sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" core check-update |grep -v -i -q -- "success"
|
2017-02-15 15:02:03 +01:00
|
|
|
|
then
|
|
|
|
|
touch "${WP_CORE_UPDATE_LOG}"
|
|
|
|
|
#printf '%b' "Please upgrade WordPress\n"
|
|
|
|
|
else
|
|
|
|
|
rm -f "${WP_CORE_UPDATE_LOG}"
|
|
|
|
|
#printf '%b' "Nothing to do\n"
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-15 14:50:07 +01:00
|
|
|
|
# Verify if updates are availables for plugins
|
2017-02-15 16:11:56 +01:00
|
|
|
|
if sudo -u www-data -- "${WP_CLI_PATH}" --path="${WP_ROOT}" plugin list|grep -q -i -- "available"
|
2017-02-15 14:50:07 +01:00
|
|
|
|
then
|
|
|
|
|
touch "${WP_PLUGIN_UPDATE_LOG}"
|
2017-02-15 15:02:03 +01:00
|
|
|
|
#printf '%b' "Please upgrade plugins\n"
|
2017-02-15 14:50:07 +01:00
|
|
|
|
else
|
|
|
|
|
rm -f "${WP_PLUGIN_UPDATE_LOG}"
|
2017-02-15 15:02:03 +01:00
|
|
|
|
#printf '%b' "Nothing to do\n"
|
2017-02-15 12:16:46 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit 0
|