|
Packit |
23ab03 |
#! @PERL@
|
|
Packit |
23ab03 |
# Copyright (c) 2009-2012 Zmanda Inc. All Rights Reserved.
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# This program is free software; you can redistribute it and/or
|
|
Packit |
23ab03 |
# modify it under the terms of the GNU General Public License
|
|
Packit |
23ab03 |
# as published by the Free Software Foundation; either version 2
|
|
Packit |
23ab03 |
# of the License, or (at your option) any later version.
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit |
23ab03 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
23ab03 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
23ab03 |
# for more details.
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# You should have received a copy of the GNU General Public License along
|
|
Packit |
23ab03 |
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit |
23ab03 |
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# Contact information: Carbonite Inc., 756 N Pastoria Ave
|
|
Packit |
23ab03 |
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
use lib '@amperldir@';
|
|
Packit |
23ab03 |
use strict;
|
|
Packit |
23ab03 |
use warnings;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
package main;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
use Amanda::Util qw( :constants );
|
|
Packit |
23ab03 |
use Amanda::Config qw( :init :getconf );
|
|
Packit |
23ab03 |
use Amanda::Logfile qw( :logtype_t log_add $amanda_log_trace_log );
|
|
Packit |
23ab03 |
use Amanda::Debug qw( debug );
|
|
Packit |
23ab03 |
use Amanda::Taper::Controller;
|
|
Packit |
23ab03 |
use Getopt::Long;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
Amanda::Util::setup_application("taper", "server", $CONTEXT_DAEMON, "amanda", "amanda");
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $config_overrides = new_config_overrides($#ARGV+1);
|
|
Packit |
23ab03 |
my $opt_storage_name;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
debug("Arguments: " . join(' ', @ARGV));
|
|
Packit |
23ab03 |
Getopt::Long::Configure(qw{bundling});
|
|
Packit |
23ab03 |
GetOptions(
|
|
Packit |
23ab03 |
'version' => \&Amanda::Util::version_opt,
|
|
Packit |
23ab03 |
'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
|
|
Packit |
23ab03 |
'storage-name=s' => \$opt_storage_name,
|
|
Packit |
23ab03 |
'log-filename=s' => sub { Amanda::Logfile::set_logname($_[1]); },
|
|
Packit |
23ab03 |
) or usage();
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
if (@ARGV != 1) {
|
|
Packit |
23ab03 |
die "USAGE: taper <config> <config-overwrites>";
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
set_config_overrides($config_overrides);
|
|
Packit |
23ab03 |
config_init_with_global($CONFIG_INIT_EXPLICIT_NAME, $ARGV[0]);
|
|
Packit |
23ab03 |
my ($cfgerr_level, @cfgerr_errors) = config_errors();
|
|
Packit |
23ab03 |
if ($cfgerr_level >= $CFGERR_WARNINGS) {
|
|
Packit |
23ab03 |
config_print_errors();
|
|
Packit |
23ab03 |
if ($cfgerr_level >= $CFGERR_ERRORS) {
|
|
Packit |
23ab03 |
die "Errors processing config file";
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
# our STDERR is connected to the amdump log file, so be sure to do unbuffered
|
|
Packit |
23ab03 |
# writes to that file
|
|
Packit |
23ab03 |
my $old_fh = select(STDERR);
|
|
Packit |
23ab03 |
$| = 1;
|
|
Packit |
23ab03 |
select($old_fh);
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
log_add($L_INFO, "taper pid $$");
|
|
Packit |
23ab03 |
Amanda::Debug::add_amanda_log_handler($amanda_log_trace_log);
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
Amanda::Util::finish_setup($RUNNING_AS_DUMPUSER);
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $tlf = Amanda::Config::config_dir_relative(getconf($CNF_TAPELIST));
|
|
Packit |
23ab03 |
my ($tl, $message) = Amanda::Tapelist->new($tlf);
|
|
Packit |
23ab03 |
if (defined $message) {
|
|
Packit |
23ab03 |
die "Could not read the tapelist: $message";
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
# transfer control to the Amanda::Taper::Controller class implemented above
|
|
Packit |
23ab03 |
my $controller = Amanda::Taper::Controller->new(
|
|
Packit |
23ab03 |
storage_name => $opt_storage_name,
|
|
Packit |
23ab03 |
tapelist => $tl);
|
|
Packit |
23ab03 |
$controller->start();
|
|
Packit |
23ab03 |
Amanda::MainLoop::run();
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
log_add($L_INFO, "pid-done $$");
|
|
Packit |
23ab03 |
Amanda::Util::finish_application();
|