diff options
author | Peter Palfrader <peter@palfrader.org> | 2002-08-05 17:30:09 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2002-08-05 17:30:09 +0000 |
commit | f53580f49eab1577853aa3fe41e86dde386016f5 (patch) | |
tree | b2a65bb4477bf7ba48e0df6401f4d04268eca0b5 /Echolot | |
parent | 855aacac4b3292aac15a49293985f4c7f7f40049 (diff) |
Using a sane basedir by defaultecholot-2.0beta21
Beta21
Diffstat (limited to 'Echolot')
-rw-r--r-- | Echolot/Config.pm | 30 |
1 files changed, 17 insertions, 13 deletions
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 <peter@palfrader.org> -# $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<ECHOLOT_CONF> environment variable -=item `pwd`/pingd.conf +=item <basedir>/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}; |