added SearchHideShare regex to config
[BackupPC.git] / lib / BackupPC / Lib.pm
index c13fc48..6e1fe8f 100644 (file)
@@ -11,7 +11,7 @@
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # COPYRIGHT
-#   Copyright (C) 2001-2007  Craig Barratt
+#   Copyright (C) 2001-2009  Craig Barratt
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 #
 #========================================================================
 #
-# Version 3.2.0beta0, released 17 Jan 2009.
+# Version 3.2.0, released 31 Jul 2010.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -96,7 +96,7 @@ sub new
     # Whether to use filesystem hierarchy standard for file layout.
     # If set, text config files are below /etc/BackupPC.
     #
-    my $useFHS = 0;
+    my $useFHS = 1;
     my $paths;
 
     #
@@ -105,6 +105,8 @@ sub new
     $topDir     = '/data/BackupPC' if ( $topDir eq "" );
     $installDir = '/usr/local/BackupPC'    if ( $installDir eq "" );
 
+       $confDir = '/etc/BackupPC'; # FIXME remove this! XXX
+
     #
     # Pick some initial defaults.  For FHS the only critical
     # path is the ConfDir, since we get everything else out
@@ -130,7 +132,7 @@ sub new
 
     my $bpc = bless {
        %$paths,
-        Version => '3.2.0beta0',
+        Version => '3.2.0',
     }, $class;
 
     $bpc->{storage} = BackupPC::Storage->new($paths);
@@ -364,9 +366,9 @@ sub ConfigRead
     # Read host config file
     #
     if ( $host ne "" ) {
-       ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host);
+       ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host, $config);
        return $mesg if ( defined($mesg) );
-       $bpc->{Conf} = { %{$bpc->{Conf}}, %$config };
+       $bpc->{Conf} = $config;
     }
 
     #
@@ -1236,19 +1238,24 @@ sub cmdVarSubstitute
     # Merge variables into @cmd
     #
     foreach my $arg ( @$template ) {
+        #
+        # Replace $VAR with ${VAR} so that both types of variable
+        # substitution are supported
+        #
+        $arg =~ s[\$(\w+)]{\${$1}}g;
         #
         # Replace scalar variables first
         #
-        $arg =~ s{\$(\w+)(\+?)}{
+        $arg =~ s[\${(\w+)}(\+?)]{
             exists($vars->{$1}) && ref($vars->{$1}) ne "ARRAY"
                 ? ($2 eq "+" ? $bpc->shellEscape($vars->{$1}) : $vars->{$1})
-                : "\$$1$2"
+                : "\${$1}$2"
         }eg;
         #
         # Now replicate any array arguments; this just works for just one
         # array var in each argument.
         #
-        if ( $arg =~ m{(.*)\$(\w+)(\+?)(.*)} && ref($vars->{$2}) eq "ARRAY" ) {
+        if ( $arg =~ m[(.*)\${(\w+)}(\+?)(.*)] && ref($vars->{$2}) eq "ARRAY" ) {
             my $pre  = $1;
             my $var  = $2;
             my $esc  = $3;