here is a patch that solve this in simplest way.
i don't yet test it - it is just for example as possible solution...
Code:
# diff -updr /root/development/trunk/engine /work/
diff -updr /root/development/trunk/engine/ispcp_common_code.pl /work/ispcp_common_code.pl
--- /root/development/trunk/engine/ispcp_common_code.pl 2007-05-27 13:00:16.000000000 +0700
+++ /work/ispcp_common_code.pl 2007-05-27 12:50:27.000000000 +0700
@@ -87,6 +87,7 @@ BEGIN {
}
}
+$main::backup_ext = '.ispcp_backup';
#$main::engine_debug = '_on_';
@@ -459,7 +460,7 @@ sub get_file {
sub store_file {
- my ($fname, $fdata, $fuid, $fgid, $fperms) = @_;
+ my ($fname, $fdata, $fuid, $fgid, $fperms, $to_backup) = @_;
push_el(\@main::el, 'store_file()', 'Starting...');
@@ -479,6 +480,23 @@ sub store_file {
return -1;
}
+ if ( ( -e $fname ) && $to_backup )
+ {
+ my $backup_extension = $main::backup_ext;
+ my $cmd = "$main::cfg{'CMD_CP'} -f $fname $fname$backup_extension";
+ my $rs = sys_command_rs($cmd);
+ if ($rs != 0)
+ {
+ push_el(
+ \@main::el,
+ ((caller(0))[3]) . '()',
+ "ERROR: Can not create backup copy '$fname$backup_extension' of '$fname' - copying failed with '$rs'"
+ );
+
+ return -1;
+ }
+ }
+
my $res = open(F, '>', $fname);
if (!defined($res)) {
diff -updr /root/development/trunk/engine/setup/ispcp-setup /work/setup/ispcp-setup
--- /root/development/trunk/engine/setup/ispcp-setup 2007-05-27 13:00:17.000000000 +0700
+++ /work/setup/ispcp-setup 2007-05-27 12:31:16.000000000 +0700
@@ -1414,8 +1414,8 @@ sub setup_resolver {
if ($main::cfg{'SECONDARY_DNS'} ne '') {
$data .= "nameserver $main::cfg{'SECONDARY_DNS'}\n";
}
-
- $rs = store_file("/etc/resolv.conf", $data, 'root', 'root', 0644);
+ my $to_backup = 1;
+ $rs = store_file("/etc/resolv.conf", $data, 'root', 'root', 0644, $to_backup);
return $rs if ($rs != 0);
@@ -1437,8 +1437,8 @@ sub setup_hosts {
my $hostname_local = "$hostname.local";
my $ip = $main::ua{'eth_ip'};
-
- $rs = store_file("/etc/hosts", "\n# 'hosts' file configuration.\n\n127.0.0.1\t$hostname_local\tlocalhost\n$ip\t$hostname\t$host\n::ffff:$ip\t$hostname\t$host\n::1\tip6-localhost ip6-loopback\nfe00::0\tip6-localnet\nff00::0\tip6-mcastprefix\nff02::1\tip6-allnodes\nff02::2\tip6-allrouters\nff02::3\tip6-allhosts", 'root', 'root', 0644);
+ my $to_backup = 1;
+ $rs = store_file("/etc/hosts", "\n# 'hosts' file configuration.\n\n127.0.0.1\t$hostname_local\tlocalhost\n$ip\t$hostname\t$host\n::ffff:$ip\t$hostname\t$host\n::1\tip6-localhost ip6-loopback\nfe00::0\tip6-localnet\nff00::0\tip6-mcastprefix\nff02::1\tip6-allnodes\nff02::2\tip6-allrouters\nff02::3\tip6-allhosts", 'root', 'root', 0644, $to_backup);
return $rs if ($rs != 0);