/[pdpsoft]/nl.nikhef.pdp.fetchcrl/trunk/fetch-crl3.pl.cin
ViewVC logotype

Diff of /nl.nikhef.pdp.fetchcrl/trunk/fetch-crl3.pl.cin

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

nl.nikhef.pdp.fetchcrl/trunk/fetch-crl3.pl revision 2305 by davidg, Sun Jun 12 20:59:58 2011 UTC nl.nikhef.pdp.fetchcrl/trunk/fetch-crl3.pl.cin revision 2692 by davidg, Wed Mar 5 19:43:36 2014 UTC
# Line 25  use Getopt::Long qw(:config no_ignore_ca Line 25  use Getopt::Long qw(:config no_ignore_ca
25  use POSIX;  use POSIX;
26  eval { require LWP or die; }; $@ and die "Please install libwww-perl (LWP)\n";  eval { require LWP or die; }; $@ and die "Please install libwww-perl (LWP)\n";
27    
28    my $sccsid = '@(#)$Id$';
29    
30  # import modules that are needed but still external  # import modules that are needed but still external
31  # (the installed version may have these packages embedded in-line)  # (the installed version may have these packages embedded in-line)
32  #  #
# Line 46  use vars qw/ $log $cnf /; Line 48  use vars qw/ $log $cnf /;
48  #  #
49  ($cnf,$log) = &init_configuration();  ($cnf,$log) = &init_configuration();
50    
51    # use Net::INET6Glue if so requested (is not a default module)
52    if ( $cnf->{_}->{inet6glue} ) {
53      eval { require Net::INET6Glue::INET_is_INET6 or die; };
54      $@ and die "Please install Net::INET6Glue before enabling inet6glue config\n";
55    }
56    
57  # verify local installation sanity for loaded modules  # verify local installation sanity for loaded modules
58  $::log->getverbose > 6 and ! $use_DataDumper and  $::log->getverbose > 6 and ! $use_DataDumper and
59    $::log->err("Cannot set verbosity higher than 6 without Data::Dumper") and    $::log->err("Cannot set verbosity higher than 6 without Data::Dumper") and
# Line 59  $use_DataDumper and $::log->verb(7,Data: Line 67  $use_DataDumper and $::log->verb(7,Data:
67  # set safe path if so requested  # set safe path if so requested
68  $cnf->{_}->{path} and $ENV{"PATH"} = $cnf->{_}->{path} and  $cnf->{_}->{path} and $ENV{"PATH"} = $cnf->{_}->{path} and
69    $::log->verb(5,"Set PATH to",$ENV{"PATH"});    $::log->verb(5,"Set PATH to",$ENV{"PATH"});
70    
71    # set rcmode if present in config
72    defined $cnf->{_}->{rcmode} and do {
73      $::log->verb(4,"Setting exit status mode to ".$cnf->{_}->{rcmode});
74      $::log->setrcmode($cnf->{_}->{rcmode}) or exit($log->exitstatus);
75      $::log->verb(2,"Exit status mode is set to ".$cnf->{_}->{rcmode});
76    };
77        
78  # wait up to randomwait seconds to spread download load  # wait up to randomwait seconds to spread download load
79  $cnf->{_}->{randomwait} and do {  $cnf->{_}->{randomwait} and do {
# Line 109  sub init_configuration() { Line 124  sub init_configuration() {
124    my $verbosity;    my $verbosity;
125    my $quiet=0;    my $quiet=0;
126    my $help=0;    my $help=0;
127      my $showversion=0;
128    my $debuglevel;    my $debuglevel;
129    my $parallelism=0;    my $parallelism=0;
130    my $randomwait;    my $randomwait;
131    my $nosymlinks;    my $nosymlinks;
132    my $cfgdir;    my $cfgdir;
133      my $inet6glue=0;
134      my %directives;
135    
136    $log = FCLog->new("qualified");    $log = FCLog->new("qualified");
137    
# Line 126  sub init_configuration() { Line 144  sub init_configuration() {
144      "T|httptimeout=i" => \$httptimeout,      "T|httptimeout=i" => \$httptimeout,
145      "o|output=s" => \$output,      "o|output=s" => \$output,
146      "format=s@" => \@formats,      "format=s@" => \@formats,
147        "define=s" => \%directives,
148      "v|verbose+" => \$verbosity,      "v|verbose+" => \$verbosity,
149      "h|help+" => \$help,      "h|help+" => \$help,
150        "V|version+" => \$showversion,
151      "q|quiet+" => \$quiet,      "q|quiet+" => \$quiet,
152      "d|debug+" => \$debuglevel,      "d|debug+" => \$debuglevel,
153      "p|parallelism=i" => \$parallelism,      "p|parallelism=i" => \$parallelism,
154      "nosymlinks+" => \$nosymlinks,      "nosymlinks+" => \$nosymlinks,
155      "a|agingtolerance=i" => \$agingtolerance,      "a|agingtolerance=i" => \$agingtolerance,
156      "r|randomwait=i" => \$randomwait,      "r|randomwait=i" => \$randomwait,
157        "inet6glue+" => \$inet6glue,
158      ) or &help and exit(1);      ) or &help and exit(1);
159    
160    $help and &help and exit(0);    $help and &help and exit(0);
161      $showversion and &showversion and exit(0);
162    
163    $configfile ||= ( -e "/etc/fetch-crl.conf" and "/etc/fetch-crl.conf" );    $configfile ||= ( -e "/etc/fetch-crl.conf" and "/etc/fetch-crl.conf" );
164    $configfile ||= ( -e "/etc/fetch-crl.cnf" and "/etc/fetch-crl.cnf" );    $configfile ||= ( -e "/etc/fetch-crl.cnf" and "/etc/fetch-crl.cnf" );
   ($quiet > 0) and $verbosity = -$quiet;  
165    
166    $cnf = ConfigTiny->new();    $cnf = ConfigTiny->new();
167    $configfile and    $configfile and
# Line 157  sub init_configuration() { Line 178  sub init_configuration() {
178      close $dh;      close $dh;
179    }    }
180    
181      # add defined from the command line to the configuration, to the
182      # main section _ thereof unless there is a colon in the key
183      foreach my $k ( keys %directives ) {
184        my $section ="_";
185        my $dvalue = $directives{$k};
186        if ( $k =~ m/(\w+):(.*)/ ) {
187          $section = $1;
188          $k=$2;
189        }
190        $cnf->{$section}->{$k} = $dvalue;
191      }
192    
193    # command-line option overrides    # command-line option overrides
194    $cnf->{_}->{agingtolerance} = $agingtolerance if defined $agingtolerance;    $cnf->{_}->{agingtolerance} = $agingtolerance if defined $agingtolerance;
195    $cnf->{_}->{infodir}        = $infodir if defined $infodir;    $cnf->{_}->{infodir}        = $infodir if defined $infodir;
# Line 170  sub init_configuration() { Line 203  sub init_configuration() {
203    $cnf->{_}->{parallelism}    = $parallelism if $parallelism;    $cnf->{_}->{parallelism}    = $parallelism if $parallelism;
204    $cnf->{_}->{randomwait}     = $randomwait if defined $randomwait;    $cnf->{_}->{randomwait}     = $randomwait if defined $randomwait;
205    $cnf->{_}->{nosymlinks}     = $nosymlinks if defined $nosymlinks;    $cnf->{_}->{nosymlinks}     = $nosymlinks if defined $nosymlinks;
206      $cnf->{_}->{inet6glue}      = $inet6glue if $inet6glue;
207    
208      # deal with interaction of verbosity in logfile and quiet option
209      # since a noquiet config option can cancel it
210      if ( not defined $cnf->{_}->{noquiet} ) {
211        if ( $quiet == 1) { $cnf->{_}->{verbosity} = -1; }
212      } else {
213        if ( $quiet >= 2) { $cnf->{_}->{verbosity} = -1; }
214      }
215    
216    # key default values    # key default values
217    defined $cnf->{_}->{version}  or $cnf->{_}->{version}    = "3+";    defined $cnf->{_}->{version}  or $cnf->{_}->{version}    = "3+";
# Line 196  sub init_configuration() { Line 238  sub init_configuration() {
238    $cnf->{_}->{nosymlinks}     ||= 0;    $cnf->{_}->{nosymlinks}     ||= 0;
239    $cnf->{_}->{verbosity}      ||= 0;    $cnf->{_}->{verbosity}      ||= 0;
240    $cnf->{_}->{debuglevel}     ||= 0;    $cnf->{_}->{debuglevel}     ||= 0;
241      $cnf->{_}->{inet6glue}      ||= 0;
242    
243    $cnf->{_}->{stateless} and delete $cnf->{_}->{statedir};    $cnf->{_}->{stateless} and delete $cnf->{_}->{statedir};
244    
# Line 227  sub init_configuration() { Line 270  sub init_configuration() {
270  # ###########################################################################  # ###########################################################################
271  #  #
272  #  #
273    sub showversion() {
274      (my $name = $0) =~ s/.*\///;
275      print "$name version @VERSION@\n";
276      return 1;
277    }
278    
279  sub help() {  sub help() {
280    (my $name = $0) =~ s/.*\///;    (my $name = $0) =~ s/.*\///;
281  print <<EOHELP;  print <<EOHELP;
# Line 273  Options: Line 322  Options:
322   -h | --help   -h | --help
323          This help text          This help text
324    
325    Version: @VERSION@
326  EOHELP  EOHELP
327    
328    return 1;    return 1;
# Line 289  sub process_metafiles(@) { Line 339  sub process_metafiles(@) {
339        $cnf->{_}->{"infodir"} and $ta->setInfodir($cnf->{_}->{"infodir"});        $cnf->{_}->{"infodir"} and $ta->setInfodir($cnf->{_}->{"infodir"});
340        $ta->loadAnchor($f) or next;        $ta->loadAnchor($f) or next;
341        $ta->saveLogMode() and $ta->setLogMode();        $ta->saveLogMode() and $ta->setLogMode();
       $ta->loadCAfiles() or next;  
342        $ta->loadState() or next;        $ta->loadState() or next;
343        $ta->retrieve or next;  
344          # using the HASH in the CA filename templates requires the CRL
345          # is retrieved first to determinte the hash
346          if ( $cnf->{_}->{"catemplate"} =~ /\@HASH\@/ ) {
347            $ta->retrieve or next;
348            $ta->loadCAfiles() or next;
349          } else {
350            $ta->loadCAfiles() or next;
351            $ta->retrieve or next;
352          }
353    
354        $ta->verifyAndConvertCRLs or next;        $ta->verifyAndConvertCRLs or next;
355            
356        my $writer = CRLWriter->new($ta);        my $writer = CRLWriter->new($ta);

Legend:
Removed from v.2305  
changed lines
  Added in v.2692

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28