This commit is contained in:
cronekorkn 2024-02-04 14:31:42 +01:00
parent 88d21ca1e5
commit 6f972fddd2
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
6 changed files with 59 additions and 7 deletions

View file

@ -0,0 +1 @@
https://developer.wordpress.org/advanced-administration/upgrade/upgrading/

View file

@ -0,0 +1,25 @@
#!/bin/bash
SITE=$1
VERSION=$(php -r "require('/opt/$SITE/wp-includes/version.php'); echo \$wp_version;")
STATUS=$(curl -ssL http://api.wordpress.org/core/stable-check/1.0/ | jq -r '.["'$VERSION'"]')
echo "WordPress $VERSION is '$STATUS'"
if [[ "$STATUS" == latest ]]
then
exit 0
elif [[ "$STATUS" == outdated ]]
then
exit 1
elif [[ "$STATUS" == insecure ]]
then
if test -f /etc/nginx/sites/$SITE
then
rm /etc/nginx/sites/$SITE
systemctl restart nginx
fi
exit 2
else
exit 2
fi

View file

@ -0,0 +1,5 @@
<?php
require_once '${path}/wp-includes/version.php';
echo "$wp_version";

View file

View file

@ -1,8 +1,12 @@
files = {
'/usr/lib/nagios/plugins/check_wordpress_insecure': {
'mode': '0750',
},
}
for site, conf in node.metadata.get('wordpress').items():
directories = {
f'/opt/{site}': {
'owner': 'www-data',
'group': 'www-data',
'mode': '0755',
},
directories[f'/opt/{site}'] = {
'owner': 'www-data',
'group': 'www-data',
'mode': '0755',
}

View file

@ -16,7 +16,7 @@ def wordpress(metadata):
@metadata_reactor.provides(
'mariadb',
'mariadb/databases',
)
def mariadb(metadata):
return {
@ -64,3 +64,20 @@ def zfs(metadata):
},
},
}
@metadata_reactor.provides(
'monitoring/services',
)
def check_insecure(metadata):
return {
'monitoring': {
'services': {
f'wordpress {site} insecure': {
'vars.command': f'/usr/lib/nagios/plugins/check_wordpress_insecure {site}',
'check_interval': '1h',
'vars.sudo': True,
}
for site in metadata.get('wordpress')
},
},
}