]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - tools/check_manualpages.pl
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2005-2021 IPFire Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 # Import make.sh environment
26 my $basedir = $ENV{'BASEDIR'};
28 # Load configuration file (Header::_read_manualpage_hash() isn't available yet)
29 my $configfile = "${basedir}/config/cfgroot/manualpages";
32 open(my $file, "<", $configfile) or die "ERROR: Can't read from file '$configfile'!\n";
33 while(my $line = <$file>) {
35 next if(substr($line, 0, 1) eq '#'); # Skip comments
36 next if(index($line, '=', 1) == -1); # Skip incomplete lines
38 my($left, $value) = split(/=/, $line, 2);
39 if($left =~ /^([[:alnum:]\/._
-]+)$/) {
41 $manualpages{$key} = $value;
47 if(! defined $manualpages{'BASE_URL'}) {
48 die "ERROR: User manual base URL not configured!\n";
50 my $baseurl = $manualpages{'BASE_URL'};
51 delete $manualpages{'BASE_URL'};
53 if ($baseurl =~ /\/\s
*$/) {
54 die "ERROR: User manual base URL must not end with a slash!\n";
57 # Loop trough configured manual pages
58 foreach my $page (keys %manualpages) {
59 # Build absolute path (inside cgi-bin) and URL
60 my $cgifile = "${basedir}/html/cgi-bin/${page}";
61 my $url = "${baseurl}/$manualpages{$page}";
63 print "cgi-bin/${page} -> '$url'\n";
65 # Check CGI file exists
67 print "WARNING: Obsolete link, page '$cgifile' doesn't exist!\n";
70 # Check obvious invalid characters
71 if($url =~ /[^[:graph:]]/) {
72 die("ERROR: URL contains invalid characters!\n");
75 # Check HTTP 200 "OK" result, follow up to 1 redirect (e.g. HTTP -> HTTPS)
76 my $status = `curl --silent --show-error --output /dev/null --location --max-redirs 1 --max-time 10 --write-out "%{http_code}" --url "${url}"`;
78 die("ERROR: Received unexpected HTTP '$status'!\n");
81 print "SUCCESS: Received HTTP '$status'.\n";