forked from B4Team/cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules-downcheck.pl.in
67 lines (54 loc) · 1.36 KB
/
rules-downcheck.pl.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
use strict;
# checks presence of all files in rules-archive
# just execute and correct
my $filename = "rules-archive";
my $gnuserver = "@gnuserver@";
my $defaultpath = "http://@defaultserver@";
my @entries;
print "checking existence of archives in \"$filename\"\n";
open (RULES, "< $filename") or die "Can't open \"$filename\", fix your CDK installation!";
while (<RULES>){
s/#.*//;
next if /^(\s)*$/;
chomp;
# replace gnuserver
s/\$\(gnuserver\)/$gnuserver/;
push @entries, $_;
}
close RULES;
my @errors;
my $errcnt=0;
my $pcnt=1;
foreach (@entries) {
@_ = split (/;/);
if (scalar(@_)==1){ # no path, use default
push @_,$defaultpath;
}
my $archive = @_[0];
shift (@_);
print $pcnt++.".: $archive\n";
foreach (@_){
print "\t"."$_/$archive";
my $cmd = "wget --timeout=10 --spider --passive-ftp \"$_/$archive\" 2>&1";
print " ";
my @res = `$cmd`;
if ($?) {
push @errors,@res;
print "[ERROR]\n";
$errcnt++;
} else {
print "[OK]\n";
}
}
print "\n";
}
if (!$errcnt) {
print "No errors, all archives still reachable!\n\n";
exit 0;
}
print "\n\nSummary\n-------\n$errcnt error".(($errcnt>1)?"s":"")." occured:\n\n";
foreach(@errors){
if (m/--/){ print "--------------------------------------------------------------------------------\n"; }
print;
}