X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famserverconfig.pl;h=f176f312379cea158c21b042d2633fb4ae8f2222;hb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;hp=09557cb3d8a27caabd0aa333c3df980649e0bdf0;hpb=fb2bd066c2f8b34addafe48d62550e3033a59431;p=debian%2Famanda diff --git a/server-src/amserverconfig.pl b/server-src/amserverconfig.pl index 09557cb..f176f31 100755 --- a/server-src/amserverconfig.pl +++ b/server-src/amserverconfig.pl @@ -1,6 +1,6 @@ #!@PERL@ # -# Copyright (c) 2006 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2005-2008 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 @@ -15,25 +15,21 @@ # 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, 505 N Mathlida Ave, Suite 120 -# Sunnyvale, CA 94085, USA, or: http://www.zmanda.com +# Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300 +# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com # +use lib '@amperldir@'; use Getopt::Long; use Time::Local; use File::Copy; use Socket; # for gethostbyname +use Amanda::Paths; -my $confdir="@CONFIG_DIR@"; -my $prefix="@prefix@"; -my $tmpdir="@AMANDA_DBGDIR@"; -$prefix=$prefix; # avoid warnings about possible typo -my $exec_prefix="@exec_prefix@"; -$exec_prefix=$exec_prefix; # ditto -my $sbindir="@sbindir@"; -my $localstatedir="@localstatedir@"; +my $confdir="$CONFIG_DIR"; +my $tmpdir="$AMANDA_DBGDIR"; my $amandahomedir="$localstatedir/lib/amanda"; -my $datadir="$amandahomedir/template.d"; #rpm install template files here +my $templatedir="$amdatadir/template.d"; #rpm install template files here my $def_tapedev="file:/$amandahomedir/vtapes"; my $amanda_user="@CLIENT_LOGIN@"; @@ -156,8 +152,8 @@ sub copy_template_file { &log_and_die ("ERROR: template is missing\n", 1); } # create and update amanda.conf - open(CONF, "$datadir/amanda-$tplate.conf") - || &log_and_die ("ERROR: Cannot open $datadir/amanda-$tplate.conf: $!\n", 1); + open(CONF, "$templatedir/amanda-$tplate.conf") + || &log_and_die ("ERROR: Cannot open $templatedir/amanda-$tplate.conf: $!\n", 1); open(NEWCONF, ">$confdir/$config/amanda.conf") || &log_and_die ("ERROR: Cannot create $confdir/$config/amanda.conf: $!\n", 1); chmod ($amanda_conf_perm, "$confdir/$config/amanda.conf") || @@ -433,8 +429,8 @@ sub copy_chg_manual_conf { if ( $template eq "single-tape" && !defined $changerfile && !defined $tpchanger) { my $my_changerfile="$confdir/$config/chg-manual.conf"; - copy("$datadir/chg-manual.conf", $my_changerfile) || - &mprint ("copy $datadir/chg-manual.conf to $my_changerfile failed: $!\n"); + copy("$templatedir/chg-manual.conf", $my_changerfile) || + &mprint ("copy $templatedir/chg-manual.conf to $my_changerfile failed: $!\n"); } } @@ -508,50 +504,62 @@ unless ( $host ) { } -&create_conf_dir; - +my $need_changer = 0; if ( defined $template ) { -# validate user input to template + + # validate user input to template chomp($template); my $found = 0; - @valid_templates = ( "harddisk", "single-tape", "tape-changer", "s3"); + @valid_templates = ( "harddisk", "single-tape", "tape-changer", "s3" ); foreach $elt (@valid_templates) { - if ($elt eq lc($template)) { - $found = 1; - last; - } + if ( $elt eq lc($template) ) { + $found = 1; + last; + } + } + unless ($found) { + print STDERR + "valid inputs to --templates are harddisk, single-tape, tape-changer or S3\n"; + &usage; + exit 1; } - unless ( $found ) { - print STDERR "valid inputs to --templates are harddisk, single-tape, tape-changer or S3\n"; - &usage; - exit 1; -} -# if tape-changer is chosen, check if mtx is installed - if ($template eq "tape-changer") { - my $ok = 0; - for $dir ("/usr/sbin", "/usr/local/sbin", "/usr/local/bin", "/usr/bin", "/bin","/opt/csw/sbin",split(":",$oldPATH)) { - if ( -e "$dir/mtx" ) { - $ok = 1; - last; - } - } - unless ($ok) { - &mprint ("ERROR: mtx binary not found, tape-changer template will not work and is not installed.\n"); - &log_and_die ("ERROR: Please install mtx and rerun the same command.\n", 0); - } - unless ($changerfile) {$changerfile="$confdir/$config/changer.conf";} - open (CCONF, ">$changerfile") - || &log_and_die ("ERROR: Cannot create $changerfile: $!\n", 1); - close (CCONF); - } elsif ($template eq "S3" ) { - unless ($changerfile) {$changerfile="$confdir/$config/changer.conf";} - open (CCONF, ">$changerfile") - || &log_and_die ("ERROR: Cannot create $changerfile: $!\n", 1); - close (CCONF); + # if tape-changer is chosen, check if mtx is installed + if ( $template eq "tape-changer" ) { + my $ok = 0; + for $dir ( "/usr/sbin", "/usr/local/sbin", "/usr/local/bin", + "/usr/bin", "/bin", "/opt/csw/sbin", split( ":", $oldPATH ) ) + { + if ( -e "$dir/mtx" ) { + $ok = 1; + last; + } + } + unless ($ok) { + &mprint( + "ERROR: mtx binary not found, tape-changer template will not work and is not installed.\n" + ); + &log_and_die( + "ERROR: Please install mtx and rerun the same command.\n", + 0 ); + } + $need_changer = 1; + } + elsif ( $template eq "S3" ) { + $need_changer = 1; + } - } +} + +&create_conf_dir; +if ($need_changer) { + unless ($changerfile) { + $changerfile = "$confdir/$config/changer.conf"; + } + open( CCONF, ">$changerfile" ) + || &log_and_die( "ERROR: Cannot create $changerfile: $!\n", 1 ); + close(CCONF); } &check_gnutarlist_dir; @@ -561,20 +569,20 @@ my $dtype="$confdir/template.d/dumptypes"; my $ttype="$confdir/template.d/tapetypes"; unless ( -e $dtype ) { - copy("$datadir/dumptypes", $dtype ) || + copy("$templatedir/dumptypes", $dtype ) || &log_and_die ("ERROR: copy dumptypes failed: $!\n", 1); } unless ( -e $ttype ) { - copy("$datadir/tapetypes", $ttype ) || + copy("$templatedir/tapetypes", $ttype ) || &log_and_die ("ERROR: copy tapetypes file to $ttype failed: $!\n", 1); } # update $def_config value to the specified config value in advanced.conf - open(ADV, "$datadir/advanced.conf") || &log_and_die ("ERROR: Cannot open advanced.conf file: $!\n", 1); + open(ADV, "$templatedir/advanced.conf") || &log_and_die ("ERROR: Cannot open advanced.conf file: $!\n", 1); open(NEWADV, ">$confdir/$config/advanced.conf") || &log_and_die ("ERROR: Cannot create advanced.conf file: $!\n", 1); while () {