#! @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
use lib '@amperldir@';
use strict;
+use warnings;
use Amanda::Config qw( :getconf :init );
use Amanda::Debug qw( :logging );
use Amanda::Util qw( :constants );
use Amanda::Paths;
use Amanda::Constants;
+eval 'use Amanda::Disklist;'; # can fail if compiled for client only
use Getopt::Long;
# Implementation note: this application is a bit funny, because it does not
for my $subsec (@list) {
print "$subsec\n";
}
+ } elsif ($parameter =~ /^property:/i) {
+ my %properties = %{ getconf($CNF_PROPERTY)};
+ my $propname = $parameter;
+ $propname =~ s/^property://i;
+ $propname = lc($propname);
+ if (exists $properties{$propname}) {
+ print $properties{$propname}->{'values'}[0], "\n";
+ }
+ } elsif ($parameter =~ /^device-property:/i ||
+ $parameter =~ /^device_property:/i) {
+ my %properties = %{ getconf($CNF_DEVICE_PROPERTY) };
+ my $propname = $parameter;
+ $propname =~ s/^device-property://i;
+ $propname =~ s/^device_property://i;
+ $propname = lc($propname);
+ if (exists $properties{$propname}) {
+ print $properties{$propname}->{'values'}[0], "\n";
+ }
} else {
no_such_param($parameter)
unless defined(getconf_byname($parameter));
}
}
+Amanda::Util::setup_application("amgetconf", "server", $CONTEXT_SCRIPTUTIL);
+
## Command-line parsing
my $opt_list = '';
my $config_overrides = new_config_overrides($#ARGV+1);
my $execute_where = undef;
+debug("Arguments: " . join(' ', @ARGV));
Getopt::Long::Configure(qw{bundling});
GetOptions(
+ 'version' => \&Amanda::Util::version_opt,
'list|l' => \$opt_list,
'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
'execute-where=s' => sub {
## Now start looking at the parameter.
-Amanda::Util::setup_application("amgetconf", "server", $CONTEXT_SCRIPTUTIL);
-
if ($parameter =~ /^build(?:\..*)?/) {
config_init(0|$execute_where, undef);
build_param($parameter, $opt_list);
# finally, finish up the application startup procedure
set_config_overrides($config_overrides);
-config_init($CONFIG_INIT_EXPLICIT_NAME | $CONFIG_INIT_USE_CWD | $execute_where, $config_name);
+if ($execute_where == $CONFIG_INIT_CLIENT &&
+ defined($config_name) && $config_name eq '.') {
+ config_init($CONFIG_INIT_USE_CWD | $execute_where, undef);
+} elsif ($execute_where == $CONFIG_INIT_CLIENT &&
+ defined($config_name) && $config_name ne '.') {
+ config_init($CONFIG_INIT_EXPLICIT_NAME | $execute_where, $config_name);
+} elsif ($execute_where == $CONFIG_INIT_CLIENT) {
+ config_init($execute_where, undef);
+} else {
+ config_init($CONFIG_INIT_EXPLICIT_NAME | $CONFIG_INIT_USE_CWD | $execute_where, $config_name);
+}
my ($cfgerr_level, @cfgerr_errors) = config_errors();
if ($cfgerr_level >= $CFGERR_WARNINGS) {
config_print_errors();
Amanda::Util::finish_setup($RUNNING_AS_ANY);
+if ($execute_where != $CONFIG_INIT_CLIENT) {
+ my $diskfile = Amanda::Config::config_dir_relative(getconf($CNF_DISKFILE));
+ $cfgerr_level = Amanda::Disklist::read_disklist('filename' => $diskfile);
+# if ($cfgerr_level >= $CFGERR_ERRORS) {
+# die "Errors processing disklist";
+# }
+}
+
conf_param($parameter, $opt_list);
Amanda::Util::finish_application();