Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openssl/omc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2022-06-13 19:43:53 +0300
committerRichard Levitte <levitte@openssl.org>2022-06-13 21:30:02 +0300
commitffe25b99180ef80d30e7e233a911d0a677cb22d7 (patch)
treea41bc64783de862e56920272c0f69cbe85edca5c
parentee95ad7c1b1c49e461152c478c0728b8d967c2b4 (diff)
Modify purge-one-hour to take two arguments, BASEDIR and BASEURL
Use cases, based on what we do with automation today: For the main web: purge-one-hour /var/www/openssl https://www.openssl.org For the docs: purge-one-hour /var/www/docs https://www.openssl.org/docs For the blog: purge-one-hour /var/www/blog https://www.openssl.org/blog
-rwxr-xr-xakamai-tools/purge-one-hour32
1 files changed, 26 insertions, 6 deletions
diff --git a/akamai-tools/purge-one-hour b/akamai-tools/purge-one-hour
index 895967f..c1dc3b2 100755
--- a/akamai-tools/purge-one-hour
+++ b/akamai-tools/purge-one-hour
@@ -12,15 +12,35 @@
use strict;
use warnings;
+use Cwd qw(:DEFAULT abs_path);
+use File::Basename;
+
# Find all .html files that include a .inc file, and create a map
my %inc2html = ();
my $debug = $ENV{DEBUG};
my $dryrun = $ENV{DRYRUN};
-my $base = '/var/www/openssl'; # MUST NOT end with a slash
+if (scalar @ARGV != 2 || $ARGV[0] eq '-h') {
+ my $prog = basename($0);
+ print STDERR <<_____;
+usage: $prog BASEDIR BASEURL
+
+where BASEDIR is the base directory where original web files are scanned for,
+and BASEURL is the corresponding base URL.
+_____
+ exit $ARGV[0] eq '-h' ? 0 : 1;
+}
+
+my $basedir = shift @ARGV; # For example, /var/www/openssl
+my $baseurl = shift @ARGV; # For example, https://www.openssl.org
+
+# This ensures that we have an absolute base directory, and that it's
+# normalised (i.e. doesn't have duplicated or ending slashes)
+my $tmp = abs_path($basedir) or die "$basedir: $!\n";
+$basedir = $tmp;
-foreach ( `find $base -type f -name '*.html'` ) {
+foreach ( `find $basedir -type f -name '*.html'` ) {
chomp;
my $file = $_;
my ($dn, $fn) = $_ =~ m/^(?:(.*)\/)?([^\/]*)$/;
@@ -30,7 +50,7 @@ foreach ( `find $base -type f -name '*.html'` ) {
foreach ( <HTML> ) {
if (/<!--\s*#include\s+virtual="([^"]*)"\s*-->/) {
my $vf = $1;
- $vf = ($vf =~ m|^/|) ? "$base$vf" : "$dn/$vf";
+ $vf = ($vf =~ m|^/|) ? "$basedir$vf" : "$dn/$vf";
push @incs, "$vf";
}
}
@@ -56,14 +76,14 @@ if ($debug) {
# one with an ending slash and one without.
my %files = ();
-foreach ( `find $base -type f -mtime -2` ) {
+foreach ( `find $basedir -type f -mtime -2` ) {
chomp;
- next if /^\Q$base\E\/(\.git|bin)/;
+ next if /^\Q$basedir\E\/(\.git|bin)/;
next if /\/\.ht\w+$/;
my $x = $_;
my @files = defined $inc2html{$x} ? @{$inc2html{$x}} : ( $x );
foreach ( @files ) {
- s/^\Q$base\E\//https:\/\/www.openssl.org\//;
+ s/^\Q$basedir\E\//$baseurl\//;
$files{$_} = 1;
if ( /^(.*)\/index.(html|cgi|pl|php|xhtml|htm)$/ ) {
$files{"$1/"} = $files{"$1"} = 1;