initial commit
This commit is contained in:
24
coordinator
Executable file
24
coordinator
Executable 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
|
||||||
|
|
||||||
14
neighborhoodwatch.conf-sample
Normal file
14
neighborhoodwatch.conf-sample
Normal 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
63
run.d/drupal
Executable 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
26
run.d/wordpress
Executable 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user