Merge tag 'upstream/3.3.3'
[debian/amanda] / installcheck / Installcheck / Config.pm
index 2fc3918677f6996d0d2171a67c2ea133142b15ce..d9b4a7df87c979936cac502ba2ec2aeb0f4eb217 100644 (file)
@@ -1,9 +1,10 @@
 # vim:ft=perl
-# Copyright (c) 2008,2009 Zmanda, Inc.  All Rights Reserved.
+# Copyright (c) 2008-2012 Zmanda, Inc.  All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -203,6 +204,8 @@ sub remove_param {
 =item C<add_script($name, $values_arrayref)>
 =item C<add_device($name, $values_arrayref)>
 =item C<add_changer($name, $values_arrayref)>
+=item C<add_interactivity($name, $values_arrayref)>
+=item C<add_taperscan($name, $values_arrayref)>
 
 Add the given subsection to the configuration file, including all values in the
 arrayref.  The values should be specified as alternating key/value pairs.
@@ -278,6 +281,18 @@ sub add_changer {
     $self->_add_subsec("changers", $name, 1, $values);
 }
 
+sub add_interactivity {
+    my $self = shift;
+    my ($name, $values) = @_;
+    $self->_add_subsec("interactivities", $name, 1, $values);
+}
+
+sub add_taperscan {
+    my $self = shift;
+    my ($name, $values) = @_;
+    $self->_add_subsec("taperscans", $name, 1, $values);
+}
+
 =item C<add_text($text)>
 
 Add arbitrary text to the config file.
@@ -371,9 +386,14 @@ sub _write_amanda_conf {
     # write key/value pairs
     my @params = @{$self->{'params'}};
     my $saw_tapetype = 0;
+    my $taperscan;
     while (@params) {
        $param = shift @params;
        $value = shift @params;
+       if ($param eq 'taperscan') {
+           $taperscan = $value;
+           next;
+       }
        print $amanda_conf "$param $value\n";
        $saw_tapetype = 1 if ($param eq "tapetype");
     }
@@ -392,7 +412,10 @@ sub _write_amanda_conf {
     $self->_write_amanda_conf_subsection($amanda_conf, "holdingdisk", $self->{"holdingdisks"});
     $self->_write_amanda_conf_subsection($amanda_conf, "device", $self->{"devices"});
     $self->_write_amanda_conf_subsection($amanda_conf, "changer", $self->{"changers"});
+    $self->_write_amanda_conf_subsection($amanda_conf, "interactivity", $self->{"interactivities"});
+    $self->_write_amanda_conf_subsection($amanda_conf, "taperscan", $self->{"taperscans"});
     print $amanda_conf "\n", $self->{'text'}, "\n";
+    print $amanda_conf "taperscan $taperscan\n" if $taperscan;
 
     close($amanda_conf);
 }
@@ -413,8 +436,10 @@ sub _write_amanda_conf_subsection {
            $value = shift @values;
            if ($param eq "inherit") {
                print $amanda_conf "$value\n";
-           } else {
+           } elsif (defined $value) {
                print $amanda_conf "$param $value\n";
+           } else {
+               print $amanda_conf "$param\n";
            }
        }
        print $amanda_conf "}\n";