improved drupal detection process, including support for localhost. courtesy WvR
This commit is contained in:
29
run.d/drupal
29
run.d/drupal
@@ -30,9 +30,24 @@ if($feed && $feed instanceof SimpleXMLElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For Drupal 4.x - 6.x
|
// Start checking hosts
|
||||||
|
//
|
||||||
|
if( $hosts == null ) {
|
||||||
|
checkHost(null, $dr_current);
|
||||||
|
} else {
|
||||||
foreach($hosts as $host) {
|
foreach($hosts as $host) {
|
||||||
$cmd = "ssh $host \"locate modules/system/system.module | xargs grep -H 'VERSION'\"";
|
checkHost($host, $dr_current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkHost($host, $dr_current) {
|
||||||
|
// For Drupal 4.x - 6.x
|
||||||
|
$cmd = "locate modules/system/system.module | xargs grep -H 'VERSION'";
|
||||||
|
$hostidentifier = "";
|
||||||
|
if( $host != null ) {
|
||||||
|
$cmd = "ssh $host \"" . $cmd . "\"";
|
||||||
|
$hostidentifier = $host . ":";
|
||||||
|
}
|
||||||
exec($cmd, $results);
|
exec($cmd, $results);
|
||||||
|
|
||||||
foreach($results as $instance) {
|
foreach($results as $instance) {
|
||||||
@@ -40,16 +55,16 @@ foreach($hosts as $host) {
|
|||||||
$location = substr($parts[0], 0, strlen($parts[0])-28);
|
$location = substr($parts[0], 0, strlen($parts[0])-28);
|
||||||
if(substr($parts[1], 0, 16) == "define('VERSION'") {
|
if(substr($parts[1], 0, 16) == "define('VERSION'") {
|
||||||
$version = substr($parts[1], 19, strpos($parts[1], "'", 19)-19);
|
$version = substr($parts[1], 19, strpos($parts[1], "'", 19)-19);
|
||||||
if($version < $dr_current) echo "WARNING: Outdated Drupal $version at $host:$location\n";
|
if($version < $dr_current) echo "WARNING: Outdated Drupal $version at $hostidentifier$location\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($results);
|
unset($results);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// For Drupal 7.x
|
// For Drupal 7.x
|
||||||
foreach($hosts as $host) {
|
$cmd = "locate includes/bootstrap.inc | xargs grep -H 'VERSION'";
|
||||||
$cmd = "ssh $host \"locate includes/bootstrap.inc | xargs grep -H 'VERSION'\"";
|
if( $host != null ) {
|
||||||
|
$cmd = "ssh $host \"" . $cmd . "\"";
|
||||||
|
}
|
||||||
exec($cmd, $results);
|
exec($cmd, $results);
|
||||||
|
|
||||||
foreach($results as $instance) {
|
foreach($results as $instance) {
|
||||||
|
|||||||
Reference in New Issue
Block a user