1#! @PERL@ 2# Copyright (c) 2009-2013 Zmanda Inc. All Rights Reserved. 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License 6# as published by the Free Software Foundation; either version 2 7# of the License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, but 10# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12# for more details. 13# 14# You should have received a copy of the GNU General Public License along 15# with this program; if not, write to the Free Software Foundation, Inc., 16# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17# 18# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 19# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com 20 21use lib '@amperldir@'; 22use strict; 23use warnings; 24 25package main; 26 27use Amanda::Util qw( :constants ); 28use Amanda::Config qw( :init :getconf ); 29use Amanda::Logfile qw( :logtype_t log_add $amanda_log_trace_log ); 30use Amanda::Debug qw( debug ); 31use Amanda::Taper::Controller; 32use Getopt::Long; 33 34Amanda::Util::setup_application("taper", "server", $CONTEXT_DAEMON); 35 36my $config_overrides = new_config_overrides($#ARGV+1); 37 38debug("Arguments: " . join(' ', @ARGV)); 39Getopt::Long::Configure(qw{bundling}); 40GetOptions( 41 'version' => \&Amanda::Util::version_opt, 42 'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); }, 43) or usage(); 44 45if (@ARGV != 1) { 46 die "USAGE: taper <config> <config-overwrites>"; 47} 48 49set_config_overrides($config_overrides); 50config_init($CONFIG_INIT_EXPLICIT_NAME, $ARGV[0]); 51my ($cfgerr_level, @cfgerr_errors) = config_errors(); 52if ($cfgerr_level >= $CFGERR_WARNINGS) { 53 config_print_errors(); 54 if ($cfgerr_level >= $CFGERR_ERRORS) { 55 die "Errors processing config file"; 56 } 57} 58 59# our STDERR is connected to the amdump log file, so be sure to do unbuffered 60# writes to that file 61my $old_fh = select(STDERR); 62$| = 1; 63select($old_fh); 64 65log_add($L_INFO, "taper pid $$"); 66Amanda::Debug::add_amanda_log_handler($amanda_log_trace_log); 67 68Amanda::Util::finish_setup($RUNNING_AS_DUMPUSER); 69 70my $tlf = Amanda::Config::config_dir_relative(getconf($CNF_TAPELIST)); 71my $tl = Amanda::Tapelist->new($tlf); 72# transfer control to the Amanda::Taper::Controller class implemented above 73my $controller = Amanda::Taper::Controller->new(tapelist => $tl); 74$controller->start(); 75Amanda::MainLoop::run(); 76 77log_add($L_INFO, "pid-done $$"); 78Amanda::Util::finish_application(); 79