Current time: 11-23-2024, 08:33 AM Hello There, Guest! (LoginRegister)


Post Reply 
ispcp integration behavior
Author Message
sawoy Offline
Junior Member
*

Posts: 13
Joined: May 2007
Reputation: 1
Post: #3
RE: ispcp integration behavior
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);
05-27-2007 04:10 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
ispcp integration behavior - sawoy - 05-27-2007, 06:37 AM
RE: ispcp integration behavior - joximu - 05-27-2007, 07:21 AM
RE: ispcp integration behavior - sawoy - 05-27-2007 04:10 PM
RE: ispcp integration behavior - raphael - 05-28-2007, 10:10 AM
RE: ispcp integration behavior - sawoy - 05-28-2007, 02:13 PM
RE: ispcp integration behavior - raphael - 05-29-2007, 08:26 AM
RE: ispcp integration behavior - sawoy - 05-29-2007, 08:41 AM
RE: ispcp integration behavior - raphael - 05-29-2007, 09:18 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)