* Various changes for 3.0.0beta1
[BackupPC.git] / lib / BackupPC / Storage / Text.pm
index 18f5913..72b2fba 100644 (file)
@@ -30,7 +30,7 @@
 #
 #========================================================================
 #
 #
 #========================================================================
 #
-# Version 3.0.0alpha, released 23 Jan 2006.
+# Version 3.0.0beta1, released 30 Jul 2006.
 #
 # See http://backuppc.sourceforge.net.
 #
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -247,11 +247,13 @@ sub ConfigPath
 
     return "$s->{ConfDir}/config.pl" if ( !defined($host) );
     if ( $s->{useFHS} ) {
 
     return "$s->{ConfDir}/config.pl" if ( !defined($host) );
     if ( $s->{useFHS} ) {
-        return "$s->{ConfDir}/host/$host.pl";
+        return "$s->{ConfDir}/pc/$host.pl";
     } else {
     } else {
+        return "$s->{TopDir}/pc/$host/config.pl"
+            if ( -f "$s->{TopDir}/pc/$host/config.pl" );
         return "$s->{ConfDir}/$host.pl"
             if ( $host ne "config" && -f "$s->{ConfDir}/$host.pl" );
         return "$s->{ConfDir}/$host.pl"
             if ( $host ne "config" && -f "$s->{ConfDir}/$host.pl" );
-        return "$s->{TopDir}/pc/$host/config.pl";
+        return "$s->{ConfDir}/pc/$host.pl";
     }
 }
 
     }
 }
 
@@ -287,6 +289,23 @@ sub ConfigDataRead
         $conf->{$param} = { "*" => $conf->{$param} };
     }
 
         $conf->{$param} = { "*" => $conf->{$param} };
     }
 
+    #
+    # Handle backward compatibility with defunct BlackoutHourBegin,
+    # BlackoutHourEnd, and BlackoutWeekDays parameters.
+    #
+    if ( defined($conf->{BlackoutHourBegin}) ) {
+        push(@{$conf->{BlackoutPeriods}},
+             {
+                 hourBegin => $conf->{BlackoutHourBegin},
+                 hourEnd   => $conf->{BlackoutHourEnd},
+                 weekDays  => $conf->{BlackoutWeekDays},
+             }
+        );
+        delete($conf->{BlackoutHourBegin});
+        delete($conf->{BlackoutHourEnd});
+        delete($conf->{BlackoutWeekDays});
+    }
+
     return (undef, $conf);
 }
 
     return (undef, $conf);
 }
 
@@ -340,15 +359,19 @@ sub ConfigFileMerge
                     $contents .= "\$Conf{$var} = " . $value;
                     $done->{$var} = 1;
                 }
                     $contents .= "\$Conf{$var} = " . $value;
                     $done->{$var} = 1;
                 }
-                $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/ );
-                $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ );
+                if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/
+                        || /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ ) {
+                    $endLine = $1;
+                    $skipVar = 1;
+                } else {
+                    $endLine = undef;
+                    $skipVar = /^[^#]*;/ ? 0 : 1;
+                }
                 $out = "";
                 $out = "";
-                $skipVar = 1;
             } elsif ( $skipVar ) {
             } elsif ( $skipVar ) {
-                if ( !defined($endLine) && (/^\s*[\r\n]*$/ || /^\s*#/) ) {
+                if ( !defined($endLine) && /^[^#]*;/ ) {
                     $skipVar = 0;
                     $comment = 1;
                     $skipVar = 0;
                     $comment = 1;
-                    $out .= $_;
                 }
                 if ( defined($endLine) && /^\Q$endLine\E[\n\r]*$/ ) {
                     $endLine = undef;
                 }
                 if ( defined($endLine) && /^\Q$endLine\E[\n\r]*$/ ) {
                     $endLine = undef;
@@ -428,12 +451,12 @@ sub HostInfoRead
         if ( @hdr ) {
             if ( defined($host) ) {
                 next if ( lc($fld[0]) ne lc($host) );
         if ( @hdr ) {
             if ( defined($host) ) {
                 next if ( lc($fld[0]) ne lc($host) );
-                @{$hosts{$fld[0]}}{@hdr} = @fld;
+                @{$hosts{lc($fld[0])}}{@hdr} = @fld;
                close(HOST_INFO);
                 close(LOCK);
                 return \%hosts;
             } else {
                close(HOST_INFO);
                 close(LOCK);
                 return \%hosts;
             } else {
-                @{$hosts{$fld[0]}}{@hdr} = @fld;
+                @{$hosts{lc($fld[0])}}{@hdr} = @fld;
             }
         } else {
             @hdr = @fld;
             }
         } else {
             @hdr = @fld;