#! @PERL@
-# Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
+# Copyright (c) 2008, 2009, 2010 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
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
+# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
use lib '@amperldir@';
use strict;
+use warnings;
use Amanda::Config qw( :getconf :init );
use Amanda::Debug qw( :logging );
use Amanda::Util qw( :constants );
With --list, PARAM can be one of
EOF
for my $name (keys %Amanda::Config::subsection_names) {
- print " $name\n";
+ print " $name\n"
+ if $Amanda::Config::subsection_names{$name};
}
exit(1);
}
'cc' => $Amanda::Constants::CC,
'version' => $Amanda::Constants::VERSION,
'assertions' => $Amanda::Constants::ASSERTIONS,
- 'use_version_suffixes' => $Amanda::Constants::USE_VERSION_SUFFIXES,
+ 'use_version_suffixes' => 'no', # for backward compatibility
'locking' => $Amanda::Constants::LOCKING,
# executable paths
'bsd_security' => $Amanda::Constants::BSD_SECURITY,
'bsdudp_security' => $Amanda::Constants::BSDUDP_SECURITY,
'bsdtcp_security' => $Amanda::Constants::BSDTCP_SECURITY,
- 'krb4_security' => $Amanda::Constants::KRB4_SECURITY,
'krb5_security' => $Amanda::Constants::KRB5_SECURITY,
'ssh_security' => $Amanda::Constants::SSH_SECURITY,
'rsh_security' => $Amanda::Constants::RSH_SECURITY,
sub db_param {
my ($parameter, $opt_list) = @_;
my ($appname, $filename);
+
+ # copy amgetconf pname and pcontext
+ my $pname = Amanda::Util::get_pname();
+ my $pcontext = Amanda::Util::get_pcontext();
+
if (($appname) = $parameter =~ /^dbopen\.(.*)/) {
$appname =~ s/[^[:alnum:]]/_/g;
- Amanda::Util::setup_application($appname, "server", $CONTEXT_CMDLINE);
+ # set pname and pcontext for the application
+ Amanda::Util::set_pname($appname);
+ Amanda::Util::set_pcontext($CONTEXT_CMDLINE);
+ Amanda::Debug::dbopen("server");
print Amanda::Debug::dbfn(), "\n";
} elsif (($appname, $filename) = $parameter =~ /^dbclose\.([^:]*):(.*)/) {
fail("debug file $filename does not exist") unless (-f $filename);
+ # set pname and pcontext for the application
+ Amanda::Util::set_pname($appname);
+ Amanda::Util::set_pcontext($CONTEXT_CMDLINE);
Amanda::Debug::dbreopen($filename, '');
Amanda::Debug::dbclose();
print "$filename\n";
} else {
fail("cannot parse $parameter");
}
+ # reset pname and pcontext for amgetconf
+ Amanda::Util::set_pcontext($pcontext);
+ Amanda::Util::set_pname($pname);
}
## regular configuration parameters
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_overwrites = new_config_overwrites($#ARGV+1);
+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_overwrite_opt($config_overwrites, $_[1]); },
+ 'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
'execute-where=s' => sub {
my $where = lc($_[1]);
fail("Invalid value ($_[1]) for --execute-where. Must be client or server.")
## Now start looking at the parameter.
if ($parameter =~ /^build(?:\..*)?/) {
+ config_init(0|$execute_where, undef);
build_param($parameter, $opt_list);
+ Amanda::Util::finish_application();
exit(0);
}
if ($parameter =~ /^db(open|close)\./) {
+ config_init(0|$execute_where, undef);
db_param($parameter, $opt_list);
+ Amanda::Util::finish_application();
exit(0);
}
# finally, finish up the application startup procedure
-Amanda::Util::setup_application("amgetconf", "server", $CONTEXT_SCRIPTUTIL);
-config_init($CONFIG_INIT_EXPLICIT_NAME | $CONFIG_INIT_USE_CWD | $execute_where, $config_name);
-apply_config_overwrites($config_overwrites);
+set_config_overrides($config_overrides);
+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);
conf_param($parameter, $opt_list);
+
+Amanda::Util::finish_application();