summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2002-09-21 03:24:41 +0000
committerPeter Palfrader <peter@palfrader.org>2002-09-21 03:24:41 +0000
commitb2e64a659da60e52e4393badf6565186bca12d01 (patch)
treeb6b25fbc3a9656481ee26949ced5b7a45f5c068a
parent5082f3c7fd852bae98e1c0e252ad19a9bfbb6d0c (diff)
Die immeditatly if there is no Version information in metadataecholot-2.0.2
Make regular backups of metadata and rotate them properly
-rw-r--r--Echolot/Config.pm6
-rw-r--r--Echolot/Storage/File.pm41
-rw-r--r--NEWS4
-rw-r--r--debian/changelog6
-rw-r--r--doc/pingd.conf.pod23
-rwxr-xr-xpingd8
6 files changed, 82 insertions, 6 deletions
diff --git a/Echolot/Config.pm b/Echolot/Config.pm
index a88367a..2e386b0 100644
--- a/Echolot/Config.pm
+++ b/Echolot/Config.pm
@@ -1,7 +1,7 @@
package Echolot::Config;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Config.pm,v 1.40 2002/09/12 15:41:49 weasel Exp $
+# $Id: Config.pm,v 1.41 2002/09/21 03:24:41 weasel Exp $
#
=pod
@@ -91,6 +91,9 @@ sub init($) {
getkeyconf_every_nth_time => 24*60/5, # send out the same request to the same remailer once a day
check_resurrection => 7*24*60*60, # weekly
+ metadata_backup => 8*60*60, # make backups of metadata and rotate them every 8 hours
+ metadata_backup_count => 32, # keep 32 rotations of metadata
+
pinger_interval => 5*60, # send out pings every 5 minutes
ping_every_nth_time => 48, # send out pings to the same remailer every 48 calls, i.e. every 4 hours
@@ -120,6 +123,7 @@ sub init($) {
broken1 => 'broken1.txt',
broken2 => 'broken2.txt',
sameop => 'sameop.txt',
+ gzip => 'gzip',
commands_file => 'commands.txt',
pidfile => 'pingd.pid',
diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm
index c71e4e8..b2b23d4 100644
--- a/Echolot/Storage/File.pm
+++ b/Echolot/Storage/File.pm
@@ -1,7 +1,7 @@
package Echolot::Storage::File;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: File.pm,v 1.40 2002/09/05 15:41:38 weasel Exp $
+# $Id: File.pm,v 1.41 2002/09/21 03:24:41 weasel Exp $
#
=pod
@@ -129,6 +129,7 @@ sub metadata_open($) {
flock($self->{'METADATA_FH'}, LOCK_EX) or
cluck("Cannot get exclusive lock on $filename: $!"),
return 0;
+ return 1;
};
sub metadata_close($) {
@@ -140,6 +141,7 @@ sub metadata_close($) {
close($self->{'METADATA_FH'}) or
cluck("Error when closing metadata file: $!"),
return 0;
+ return 1;
};
@@ -172,7 +174,7 @@ sub metadata_read($) {
return 0;
defined($self->{'METADATA'}->{'version'}) or
- cluck("Stored data lacks version header"),
+ confess("Stored data lacks version header"),
return 0;
($self->{'METADATA'}->{'version'} == ($METADATA_VERSION)) or
cluck("Metadata version mismatch ($self->{'METADATA'}->{'version'} vs. $METADATA_VERSION)"),
@@ -209,6 +211,41 @@ sub metadata_write($) {
return 1;
};
+sub metadata_backup($) {
+ my ($self) = @_;
+
+ my $filename = $self->{'datadir'} .'/'. $CONSTANTS->{'metadatafile'};
+ for (my $i=Echolot::Config::get()->{'metadata_backup_count'} - 1; $i>=0; $i--) {
+ rename ($filename.'.'.($i) , $filename.'.'.($i+1));
+ rename ($filename.'.'.($i).'.gz', $filename.'.'.($i+1).'.gz');
+ };
+ $filename .= '.1';
+
+
+ my $data = Data::Dumper->Dump( [ $self->{'METADATA'} ], [ 'METADATA' ] );
+ my $fh = new IO::Handle;
+ open ($fh, '>'.$filename) or
+ cluck("Cannot open $filename for writing: $!"),
+ return 0;
+ print($fh "# vim:set syntax=perl:\n") or
+ cluck("Error when writing to metadata file: $!"),
+ return 0;
+ print($fh $data) or
+ cluck("Error when writing to metadata file: $!"),
+ return 0;
+ $fh->flush();
+ close($fh) or
+ cluck("Error when closing metadata file: $!"),
+ return 0;
+
+ if (Echolot::Config::get()->{'gzip'}) {
+ system(Echolot::Config::get()->{'gzip'}, $filename) and
+ cluck("Gziping $filename faild."),
+ return 0;
+ };
+
+ return 1;
+};
diff --git a/NEWS b/NEWS
index 09fd93b..7770036 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+Changes in version 2.0.2 - 2002-09-21
+ * Die immeditatly if there is no Version information in metadata.
+ * Make regular backups of metadata and rotate them properly.
+
Changes in version 2.0.1 - 2002-09-21
* Store unkown fields from mix summary lines and put them in keyrings.
diff --git a/debian/changelog b/debian/changelog
index fbe0e63..34f42f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+echolot (2.0.2-1) unstable; urgency=low
+
+ * New upstream version.
+
+ -- Peter Palfrader <weasel@debian.org> Sat, 21 Sep 2002 05:11:37 +0200
+
echolot (2.0.1-1) unstable; urgency=low
* New upstream version.
diff --git a/doc/pingd.conf.pod b/doc/pingd.conf.pod
index 79dca05..58ce14a 100644
--- a/doc/pingd.conf.pod
+++ b/doc/pingd.conf.pod
@@ -326,8 +326,22 @@ After which time to expire files in the thesaurus directory.
Default: 'expire_thesaurus' => 21*24*60*60, # 2 weeks
Example: 'expire_thesaurus' => 7*24*60*60, # 1 week
-=back
+=item B<metadata_backup> [seconds]
+
+How often to make backups of metadata and rotate them. If gzip is set, backups
+are compressed.
+
+ Default: 'metadata_backup' => 8*60*60, # 8 hours
+ Example: 'metadata_backup' => 24*60*60, # daily
+=item B<metadata_backup_count> [integer]
+
+How many backups of metadata to keep.
+
+ Default: 'metadata_backup_count' => 32, # keep the last 32 backups
+ Example: 'metadata_backup_count' => 4, # keep 4 rotations
+
+=back
=head2 DIRECTORIES AND FILES
@@ -406,6 +420,13 @@ is used.
Default: 'gnupg' => '',
Example: 'gnupg' => '/home/pinger/bin/myGnuPG',
+=item B<gzip>
+
+Name of the gzip executable. If it is not in your PATH make sure to
+include path information.
+
+ Default: 'gnupg' => 'gzip',
+
=item B<mixhome>
The directory which is used as temporal Mixmaster home for all keyring and
diff --git a/pingd b/pingd
index 5ed26eb..20acc99 100755
--- a/pingd
+++ b/pingd
@@ -3,7 +3,7 @@
$| = 1;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: pingd,v 1.78 2002/09/21 01:45:39 weasel Exp $
+# $Id: pingd,v 1.79 2002/09/21 03:24:41 weasel Exp $
#
=pod
@@ -294,7 +294,7 @@ use POSIX qw(setsid);
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
-my $VERSION = '2.0.1';
+my $VERSION = '2.0.2';
my $redirected_stdio = 0;
@@ -332,6 +332,9 @@ sub commit_prospective_address() {
sub expire() {
Echolot::Globals::get()->{'storage'}->expire();
};
+sub metadata_backup() {
+ Echolot::Globals::get()->{'storage'}->metadata_backup();
+};
@@ -466,6 +469,7 @@ sub daemon_run($) {
$scheduler->add('buildkeys' , Echolot::Config::get()->{'buildkeys'} , 0, \&Echolot::Stats::build_keys );
$scheduler->add('buildthesaurus' , Echolot::Config::get()->{'buildthesaurus'} , 0, \&Echolot::Thesaurus::build_thesaurus );
+ $scheduler->add('metadata_backup' , Echolot::Config::get()->{'metadata_backup'} , 0, \&metadata_backup );
$scheduler->add('commitprospectives' , Echolot::Config::get()->{'commitprospectives'} , 0, \&commit_prospective_address );
$scheduler->add('expire' , Echolot::Config::get()->{'expire'} , 0, \&expire );
$scheduler->add('getkeyconf' , Echolot::Config::get()->{'getkeyconf_interval'}, 0, \&Echolot::Conf::send_requests );