chiark / gitweb /
Renewal/expiry.
authorijackson <ijackson>
Tue, 22 Jun 1999 17:45:34 +0000 (17:45 +0000)
committerijackson <ijackson>
Tue, 22 Jun 1999 17:45:34 +0000 (17:45 +0000)
bcp5-registry.pl
config.pl
database.pl
notice.txt

index 60a79bd4de7db91104d353d15f4aac5f61ab124e..217beba47c7627df58bcbee18c16398a7336d8cd 100755 (executable)
@@ -2,9 +2,21 @@
 
 use POSIX;
 
+@org_argv= @ARGV;
+$needrenew= 0;
+
 if ($ARGV[0] eq '--cgi') {
     shift @ARGV;
     $invokestyle= 'cgi';
+} elsif ($ARGV[0] eq '--expire-noconfirm') {
+    shift @ARGV;
+    $invokestyle= 'maintain';
+} elsif ($ARGV[0] eq '--expire-norenew') {
+    shift @ARGV;
+    $invokestyle= 'maintain';
+    $needrenew= 1;
+} elsif ($ARGV[0] =~ m/^--/) {
+    die "$ARGV[0] ?";
 } elsif ($ENV{'SERVER_SOFTWARE'} =~ m/^Lynx/) {
     $invokestyle= 'lynxcgi';
 } else {
@@ -15,11 +27,11 @@ if ($invokestyle eq 'manual') {
     open DEBUG,">&STDERR" or die $!;
 } elsif ($invokestyle eq 'lynxcgi') {
     open DEBUG,">>debug.txt" or die $!;
-} elsif ($invokestyle eq 'cgi') {
+} elsif ($invokestyle eq 'cgi' || $invokestyle eq 'maintain') {
     open DEBUG,">/dev/null" or die $!;
 }
 
-if ($invokestyle eq 'cgi') {
+if ($invokestyle eq 'cgi' || $invokestyle eq 'maintain') {
     $scriptdir= shift @ARGV;
     $datadir= shift @ARGV;
 } else {
@@ -27,7 +39,7 @@ if ($invokestyle eq 'cgi') {
     $datadir= '.';
 }
 
-if ($invokestyle ne 'manual') {
+if (!($invokestyle eq 'manual' || $invokestyle eq 'maintain')) {
     $ct= 'BCP5REGISTRY_CONTENTTYPEDONE';
     if (!$ENV{$ct}) {
        $|=1;
@@ -47,7 +59,7 @@ require 'networks.pl';
 require 'listdb.pl';
 require 'passwords.pl';
 
-if ($invokestyle ne 'manual') {
+if (!($invokestyle eq 'manual' || $invokestyle eq 'maintain')) {
     lock_database();
     require 'cgi-lib.pl';
     &ReadParse;
@@ -90,7 +102,6 @@ $details= 0;
 $fulldetails= 0;
 $justcreated= 0;
 $justupdated= 0;
-$needrenew= 0;
 $picked= 0;
 $listingall= 0;
 $passwordsent= 0;
@@ -109,7 +120,53 @@ $listingoverlap= length $listoverlap;
 
 defined($now= time) or die $!;
 
-if (length $in{'register'}) {
+if ($invokestyle eq 'maintain') {
+
+    lock_database();
+    read_database();
+
+    if ($needrenew) {
+       $threshold_recent= $now - $renew_interval;
+       $threshold_old= $threshold_recent - $expire_norenew;
+    } else {
+       $threshold= $now - $expire_noconfirm;
+    }
+
+    $changed= 0;
+
+    foreach $id (keys %db) {
+       $ent= $db{$id};
+       if ($needrenew) {
+           next unless $ent->{'changed'};
+           next if $ent->{'changed'} >= $threshold_recent;
+           if ($ent->{'changed'} > $threshold_old) {
+               show_entry();
+               send_password();
+               print "sent renewal for $id ($net)\n" or die $!;
+               next;
+           }
+           show_entry();
+           printf("deleted stale %s (%s, %x %x %x)\n",
+                  $id, $net, $threshold_recent, $threshold_old,
+                  $ent->{'changed'}) or die $!;
+       } else {
+           next if $ent->{'changed'};
+           next if $ent->{'created'} >= $threshold;
+           show_entry();
+           printf("deleted new %s (%s, %x %x)\n",
+                  $id, $net, $threshold, $ent->{'created'}) or die $!;
+       }
+       delete $db{$id};
+       $changed= 1;
+    }
+
+    if ($changed) {
+       write_database();
+    }
+    close STDOUT or die $!;
+    exit 0;
+
+} elsif (length $in{'register'}) {
     
     lock_database();
     read_database();
index a9bb4c9ede18678cbeaef19365f79ab0cc70cd9d..a87407e9363e6f3b8d087a9bb45c98a76de7c5d5 100644 (file)
--- a/config.pl
+++ b/config.pl
@@ -7,4 +7,8 @@ $emailboxlen= 55;
 $nullemail= 'discard-all@chiark.greenend.org.uk';
 $cgi= 'http://www.chiark.greenend.org.uk/ucgi/~ijackson/cam-grin';
 
+$expire_noconfirm= 48*3600;
+$renew_interval= 356*86400;
+$expire_norenew= 4*7*86400;
+
 $ENV{'PATH'}= '/usr/local/bin:/bin:/usr/bin';
index 8bbd8fdbb90ce4ec4712a17aa289aff8273d4909..6204043e2de66dab9d4ece8e3856cb402c15d1cf 100644 (file)
@@ -44,7 +44,7 @@ print DEBUG "locking\n";
     die if $db_read;
     return if $ENV{$db_lock_env};
     $ENV{$db_lock_env}= '1';
-    exec 'with-lock-ex','-w','lockfile',"$0",@ARGV;
+    exec 'with-lock-ex','-w','lockfile',"$0",@org_argv;
     die "$ENV{'PATH'}: $!";
 }
 
index 0b10783ba0d313367669c68151b6ac75de1be91e..4fdf0fb050d5ffed89f510c4a9ed1e49908092e9 100644 (file)
@@ -1,5 +1,5 @@
 From: "@@@adminname@@@" (@@@whose@@@ G-RIN administrator) <@@@adminemail@@@>
-To: "@@@contact@@@" <@@@email@@@>
+To: "@@@contact@@@" <@@@alwaysemail@@@>
 
 @@@if:justcreated@@@
 Subject: G-RIN entry @@@net@@@ created, please confirm
@@ -19,8 +19,8 @@ mailed out for the following entry in the @@@whose@@@ G-RIN:
 Subject: G-RIN entry @@@net@@@ renewal
 @@@
 The following database entry in the @@@whose@@@ G-RIN
-is now due for renewal.  It will be discarded from the database in few
-weeks if you do not confirm it before then.
+is now due for renewal.  It will be discarded from the database
+shortly if you do not confirm it before then.
 @@@endif:@@@
 @@@
 
@@ -46,8 +46,8 @@ or you may simply visit the following URL for instant confirmation:
 @@@endif:@@@
 
 @@@if:needrenew@@@
-You may renew it by using the G-RIN web page or you may simply visit
-the following URL for instant renewal:
+You can renew it by using the G-RIN web page or you may simply
+visit the following URL for instant renewal:
 @@@endif:@@@
 
 @@@if:justcreated|needrenew@@@
@@ -56,8 +56,8 @@ the following URL for instant renewal:
 @@@endif:@@@
 
 @@@if:passwordsent@@@
-You may modify this entry via the G-RIN web page, or you may go
-directly to the view/update page for this entry:
+You can modify this entry via the G-RIN web pages, or you may
+go directly to the view/update page for this entry:
 @@@
 @@@cgi@@@?view=1&id=@@@id@@@&pw=@@@password@@@
 @@@endif:@@@