commit 088be8447cbdd16e7c7fee4526b0aa9e4beadcc4 Author: florian Date: Sun Sep 22 15:23:53 2013 +0000 initial commit diff --git a/coordinator b/coordinator new file mode 100755 index 0000000..76bfc1f --- /dev/null +++ b/coordinator @@ -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 + diff --git a/neighborhoodwatch.conf-sample b/neighborhoodwatch.conf-sample new file mode 100644 index 0000000..a92fa5e --- /dev/null +++ b/neighborhoodwatch.conf-sample @@ -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" + diff --git a/run.d/drupal b/run.d/drupal new file mode 100755 index 0000000..b463d37 --- /dev/null +++ b/run.d/drupal @@ -0,0 +1,63 @@ +#!/usr/bin/php -q + 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); + +} + +?> diff --git a/run.d/wordpress b/run.d/wordpress new file mode 100755 index 0000000..41ba747 --- /dev/null +++ b/run.d/wordpress @@ -0,0 +1,26 @@ +#!/usr/bin/php -q +