From f53580f49eab1577853aa3fe41e86dde386016f5 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 5 Aug 2002 17:30:09 +0000 Subject: Using a sane basedir by default Beta21 --- Echolot/Config.pm | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'Echolot') diff --git a/Echolot/Config.pm b/Echolot/Config.pm index d90f304..8cb5237 100644 --- a/Echolot/Config.pm +++ b/Echolot/Config.pm @@ -1,7 +1,7 @@ package Echolot::Config; # (c) 2002 Peter Palfrader -# $Id: Config.pm,v 1.32 2002/07/23 00:30:11 weasel Exp $ +# $Id: Config.pm,v 1.33 2002/08/05 17:30:09 weasel Exp $ # =pod @@ -23,7 +23,7 @@ The configuration file is searched in those places in that order: =item the file pointed to by the B environment variable -=item `pwd`/pingd.conf +=item /pingd.conf =item $HOME/echolot/pingd.conf @@ -43,17 +43,19 @@ use English; my $CONFIG; -my @CONFIG_FILES = - ( $ENV{'ECHOLOT_CONF'}, - 'pingd.conf', - $ENV{'HOME'}.'/echolot/pingd.conf', - $ENV{'HOME'}.'/pingd.conf', - $ENV{'HOME'}.'/.pingd.conf', - '/etc/pingd.conf' ); - sub init($) { my ($params) = @_; - + + die ("Basedir is not defined\n") unless defined $params->{'basedir'}; + + my @CONFIG_FILES = + ( $ENV{'ECHOLOT_CONF'}, + $params->{'basedir'}.'/pingd.conf', + $ENV{'HOME'}.'/echolot/pingd.conf', + $ENV{'HOME'}.'/pingd.conf', + $ENV{'HOME'}.'/.pingd.conf', + '/etc/pingd.conf' ); + my $DEFAULT; $DEFAULT = { # System Specific Options @@ -176,6 +178,7 @@ sub init($) { for my $filename ( @CONFIG_FILES ) { if ( defined $filename && -e $filename ) { $configfile = $filename; + print "Using config file $configfile\n" if ($params->{'verbose'}); last; }; }; @@ -194,11 +197,12 @@ sub init($) { confess("Evaling config code from '$configfile' returned error: $EVAL_ERROR"); } + for my $key (keys %$DEFAULT) { $CONFIG->{$key} = $DEFAULT->{$key} unless defined $CONFIG->{$key}; }; - - $CONFIG->{'verbose'} = 1 if ($params->{'verbose'}); + $CONFIG->{'basedir'} = $params->{'basedir'} unless (defined $CONFIG->{'verbose'}); + $CONFIG->{'verbose'} = $params->{'verbose'} if ($params->{'verbose'}); for my $key (keys %$CONFIG) { warn ("Config option $key is not defined\n") unless defined $CONFIG->{$key}; -- cgit v1.2.3