33 lines
836 B
Bash
Executable File
33 lines
836 B
Bash
Executable File
#!/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_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 [ ! -f "${WP_CLI_PATH}" ]; then
|
||
printf '%b' "${WP_CLI_PATH} does not seem to be available.\n"
|
||
exit 1
|
||
fi
|
||
|
||
# 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
|