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 ++++++++++++++----------- NEWS | 4 ++++ doc/pingd.conf.pod | 18 +++++++-------- pingd | 66 ++++++++++++++++++++++++++++++++++++++++-------------- pingd.conf.sample | 1 - tools/pingctl | 7 ++---- 6 files changed, 81 insertions(+), 45 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 -# $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}; diff --git a/NEWS b/NEWS index 00e1bec..6345ad9 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Changes in version 2.0beta21 - 2002-08-05 + * Using a sane basedir by default. You no longer need to specify + it in pingd.conf. + Changes in version 2.0beta20 - 2002-08-02 * Added pingctl wrapper to tools. * echolot --help now gives a brief list of commands. diff --git a/doc/pingd.conf.pod b/doc/pingd.conf.pod index 296beaa..298a066 100644 --- a/doc/pingd.conf.pod +++ b/doc/pingd.conf.pod @@ -18,15 +18,6 @@ values in the $CONFIG hash. =over -=item B - -The base directory of the echolot installation. All other filenames and -directorynames are local to this directory. B changes into this -directory upon startup. - - Default: none - Example: 'homedir' => '/home/pinger/echolot', - =item B A short name for your site/pinger. Is used in the statistics produced. @@ -341,6 +332,15 @@ After which time to expire files in the thesaurus directory. =over +=item B + +The base directory of the echolot installation. All other filenames and +directorynames are local to this directory. B changes into this +directory upon startup. + + Default: The directory in which pingd is. + Example: 'homedir' => '/home/pinger/echolot', + =item B The Maildir directory which is searched for new messages. diff --git a/pingd b/pingd index d74c8da..7627340 100755 --- a/pingd +++ b/pingd @@ -3,7 +3,7 @@ $| = 1; # (c) 2002 Peter Palfrader -# $Id: pingd,v 1.51 2002/08/02 02:20:47 weasel Exp $ +# $Id: pingd,v 1.52 2002/08/05 17:30:09 weasel Exp $ # =pod @@ -153,19 +153,24 @@ Dumps the current configuration to standard output. =over -=item --verbose +=item B<--basedir> + +The home directory to which everything else is relative to. See the BASE +DIRECTORY section below. + +=item B<--verbose> Verbose mode. Causes B to print debugging messages about its progress. -=item --help +=item B<--help> Print a short help and exit sucessfully. -=item --version +=item B<--version> Print version number and exit sucessfully. -=item --nohup +=item B<--nohup> Usefull only with the B, B, B, B, B, B, B, @@ -176,13 +181,13 @@ commands after adding the command to the task list. Per default such a signal is sent. -=item --process +=item B<--process> Usefull only with the B command. Read and process the commands file on startup. -=item --detach +=item B<--detach> Usefull only with the B command. @@ -190,6 +195,19 @@ Tell B to detach. =back +=head1 BASE DIRECTORY + +The home directory to which everything else is relative to. + +Basedir defaults to whatever directory the B binary is located. It can +get overridden by the B environment variable which in turn is +weaker than the B<--basedir> setting. + +This directory is then used to locate the configuration file B (see +FILES below). + +The B setting in B finally sets the base directory. + =head1 FILES The configuration file is searched in those places in that order: @@ -198,7 +216,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 @@ -210,6 +228,16 @@ The configuration file is searched in those places in that order: =back +=head1 ENVIRONMENT + +=over + +=item ECHOLOT_CONF echolot config file (see section FILES) + +=item ECHOLOT_HOME echolot base directory (see section BASE DIRECTORY) + +=back + =head1 SIGNALS On B, B, and B B will schedule a shutdown @@ -233,10 +261,11 @@ Please report them at EURL:http://savannah.gnu.org/bugs/?group=echolotE =cut use strict; +use FindBin qw{ $Bin }; +use lib ( $Bin, "$Bin/lib" ); use Getopt::Long; use English; use Carp; -use lib qw{ . lib }; use Echolot::Config; use Echolot::Globals; use Echolot::Storage::File; @@ -251,7 +280,7 @@ use Echolot::Thesaurus; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; -my $VERSION = '2.0beta20'; +my $VERSION = '2.0beta21'; my $redirected_stdio = 0; @@ -499,15 +528,18 @@ sub hup_if_wanted($) { -my $params; +my $params = { basedir => $Bin }; +$params->{'basedir'} = $ENV{'ECHOLOT_HOME'} if (defined $ENV{'ECHOLOT_HOME'}); + Getopt::Long::config('bundling'); if (!GetOptions ( - 'help' => \$params->{'help'}, - 'version' => \$params->{'version'}, - 'verbose' => \$params->{'verbose'}, - 'nohup' => \$params->{'nohup'}, - 'detach' => \$params->{'detach'}, - 'process' => \$params->{'process'}, + 'help' => \$params->{'help'}, + 'version' => \$params->{'version'}, + 'verbose+' => \$params->{'verbose'}, + 'nohup' => \$params->{'nohup'}, + 'detach' => \$params->{'detach'}, + 'process' => \$params->{'process'}, + 'basedir' => \$params->{'basedir'}, )) { die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [-fwhv]\n"); }; diff --git a/pingd.conf.sample b/pingd.conf.sample index 256f18a..f7c2cf9 100644 --- a/pingd.conf.sample +++ b/pingd.conf.sample @@ -1,7 +1,6 @@ # vim:set syntax=perl: $CONFIG = { - 'homedir' => '/home/pinger/echolot', 'sitename' => 'unconfigured', 'my_localpart' => 'pinger', diff --git a/tools/pingctl b/tools/pingctl index b285d84..45a34ec 100755 --- a/tools/pingctl +++ b/tools/pingctl @@ -8,14 +8,13 @@ set -e ################################################################ # You perhaps want to change those items -BASEDIR=/home/weasel/projects/echolot/devel/echolot -USER=weasel +USER=echolot VERBOSE=0 +PINGD="/home/pinger/echolot/pingd" # You probably don't want to mess with stuff below this line ################################################################ -PINGD="./pingd" CHECKULIMIT=1 CHECKUID=1 @@ -68,8 +67,6 @@ else fi -cd $BASEDIR - case $1 in start) -- cgit v1.2.3