|
From: <ar...@sy...> - 2008-02-24 14:56:45
|
Author: arighi
Date: 2008-02-24 08:56:33 -0600 (Sun, 24 Feb 2008)
New Revision: 4408
Modified:
trunk/sbin/si_clusterconfig
Log:
- synchronize /etc/hosts with /var/lib/systemimager/scripts/hosts (the hosts
file used during imaging) by si_clusterconfig only when /etc/hosts changes
Modified: trunk/sbin/si_clusterconfig
===================================================================
--- trunk/sbin/si_clusterconfig 2008-02-24 14:46:40 UTC (rev 4407)
+++ trunk/sbin/si_clusterconfig 2008-02-24 14:56:33 UTC (rev 4408)
@@ -7,7 +7,6 @@
use lib "USR_PREFIX//lib/systemimager/perl";
use strict;
use Getopt::Long;
-use File::Copy;
use XML::Simple;
use SystemImager::Config;
use SystemImager::HostRange;
@@ -201,10 +200,10 @@
my $output_file;
+ # Cache XML info into a plain text file. This is needed to easily parse this
+ # file in the busybox environment when the clients are imaging.
+ $output_file = $script_dir . '/cluster.txt';
if (($update) || ($mtime != (stat($database))[9])) {
- # Cache XML info into a plain text file. This is needed to easily parse this
- # file in the busybox environment when the clients are imaging.
- $output_file = $script_dir . '/cluster.txt';
print "Caching XML configuration to $output_file ... ";
if (!XML_info_to_plain_file($output_file)) {
print "[ OK ]\n";
@@ -217,11 +216,13 @@
# XXX: not really dependent on cluster.xml, but it's better to synchronize
# /etc/hosts with the hosts known by SystemImager sometimes... -AR-
$output_file = $script_dir . '/hosts';
- print "Synchronizing /etc/hosts to $output_file ... ";
- if (!sync_etc_hosts($output_file)) {
- print "[ OK ]\n";
- } else {
- die("\nERROR: couldn't synchronize /etc/hosts to $output_file!\n");
+ if (($update) || ((stat('/etc/hosts'))[9] != (stat($output_file))[9])) {
+ print "Synchronizing /etc/hosts to $output_file ... ";
+ if (!sync_etc_hosts($output_file)) {
+ print "[ OK ]\n";
+ } else {
+ die("\nERROR: couldn't synchronize /etc/hosts to $output_file!\n");
+ }
}
}
@@ -331,9 +332,9 @@
{
my $dest = shift;
- system "diff /etc/hosts $dest >/dev/null 2>&1";
+ system "rsync -a /etc/hosts $dest";
if ($?) {
- copy('/etc/hosts', $dest) or return -1;
+ return -1;
}
return 0;
}
|