initial commit

This commit is contained in:
florian
2013-09-22 15:23:53 +00:00
commit 088be8447c
4 changed files with 127 additions and 0 deletions

24
coordinator Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
#################
#
# Neighborhood Watch Coordinator
#
# Discover my own location
#
SCRIPT_PATH="${BASH_SOURCE[0]}";
if ([ -h "${SCRIPT_PATH}" ]) then
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
fi
pushd . > /dev/null
cd `dirname ${SCRIPT_PATH}` > /dev/null
SCRIPT_PATH=`pwd`;
popd > /dev/null
cd ${SCRIPT_PATH}
. neighborhoodwatch.conf
run-parts $RUN_PATH

View File

@@ -0,0 +1,14 @@
#################
#
# Settings (will be sourced from main script)
#
# Hosts that need to be checked (these need to be an ssh login with keys, not passwords, hosts space separated)
#
export CHK_HOSTS="host1 host2 host3"
# Path configuration
#
export RUN_PATH="${SCRIPT_PATH}/run.d"
export TMP_PATH="${SCRIPT_PATH}/tmp"

63
run.d/drupal Executable file
View File

@@ -0,0 +1,63 @@
#!/usr/bin/php -q
<?
// Fetch the host list to check
//
$hosts = explode(' ', getenv('CHK_HOSTS'));
if (implode($hosts)=='') die("No hosts to check.\n");
// Retrieve current Drupal version as documented at http://www.goldcoastmedia.co.uk/blog/drupal-versions-with-php
//
$latest = NULL;
$url = 'http://updates.drupal.org/release-history/drupal/7.x';
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'timeout' => 10,
),
));
$data = file_get_contents($url, FALSE, $context);
if($data)
$feed = simplexml_load_string($data);
if($feed && $feed instanceof SimpleXMLElement) {
// Check the property exists and assign
if( isset($feed->releases->release[0]->version) ) {
$dr_current = $feed->releases->release[0]->version;
// return $latest;
}
}
// For Drupal 4.x - 6.x
foreach($hosts as $host) {
$cmd = "ssh $host \"locate modules/system/system.module | xargs grep -H 'VERSION'\"";
exec($cmd, $results);
foreach($results as $instance) {
$parts = explode(':', $instance);
$location = substr($parts[0], 0, strlen($parts[0])-28);
if(substr($parts[1], 0, 16) == "define('VERSION'") {
$version = substr($parts[1], 19, strpos($parts[1], "'", 19)-19);
if($version < $dr_current) echo "WARNING: Outdated Drupal $version at $host:$location\n";
}
}
unset($results);
}
// For Drupal 7.x
foreach($hosts as $host) {
$cmd = "ssh $host \"locate includes/bootstrap.inc | xargs grep -H 'VERSION'\"";
exec($cmd, $results);
foreach($results as $instance) {
$parts = explode(':', $instance);
$location = substr($parts[0], 0, strlen($parts[0])-23);
if(substr($parts[1], 0, 16) == "define('VERSION'") {
$version = substr($parts[1], 19, strpos($parts[1], "'", 19)-19);
if($version < $dr_current) echo "WARNING: Outdated Drupal $version at $host:$location\n";
}
}
unset($results);
}
?>

26
run.d/wordpress Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/php -q
<?
// Fetch the host list to check
//
$hosts = explode(' ', getenv('CHK_HOSTS'));
if (implode($hosts)=='') die("No hosts to check.\n");
// Retrieve current Wordpress version from http://api.wordpress.org/core/version-check/1.6/
//
$wp_api = unserialize(file_get_contents("http://api.wordpress.org/core/version-check/1.6/"));
$wp_current = $wp_api['offers'][0]['current'];
foreach($hosts as $host) {
$cmd = "ssh $host \"locate wp-includes/version.php | xargs grep -H 'wp_version ='\"";
exec($cmd, $results);
foreach($results as $instance) {
$parts = explode(':', $instance);
$location = substr($parts[0], 0, strlen($parts[0])-23);
$version = substr($parts[1], 15, 5);
if($version < $wp_current) echo "WARNING: Outdated Wordpress $version at $host:$location\n";
}
unset($results);
}
?>