[SVN] r519 - /branches/cyrus-db-type-check
debian at incase.de
debian at incase.de
Thu Jul 27 21:45:24 UTC 2006
Author: sven
Date: Thu Jul 27 23:45:17 2006
New Revision: 519
URL: https://mail.incase.de/viewcvs?rev=519&root=cyrus22&view=rev
Log:
Add a very preliminary db-type-compatibility checker script (for now it only reads the configs, therefor not in the package tree yet)
Added:
branches/cyrus-db-type-check (with props)
Added: branches/cyrus-db-type-check
URL: https://mail.incase.de/viewcvs/branches/cyrus-db-type-check?rev=519&root=cyrus22&view=auto
==============================================================================
--- branches/cyrus-db-type-check (added)
+++ branches/cyrus-db-type-check Thu Jul 27 23:45:17 2006
@@ -1,0 +1,137 @@
+#!/usr/bin/perl
+my $hard_db_config="/usr/lib/cyrus/cyrus-db-types.txt";
+my $old_db_config="/usr/lib/cyrus/cyrus-db-types.active";
+my $imapd_conf="/tmp/imapd.conf";
+my %old_config;
+my %running_config;
+my %used_types;
+
+sub readconfigs {
+ #
+ # read the old running config
+ #
+ # (from file named in $old_db_config)
+ open(OLDCONFIG,$old_db_config) || die "Couldn't open $hard_db_config: $!\n";
+ while (<OLDCONFIG>) {
+ chomp;
+ my $key=$_;
+ $key =~ s/ .*//;
+ my $val=$_;
+ $val =~ s/.* //;
+ $old_config{$key}=$val;
+ printf("Read value for %s as %s\n",$key,$old_config{$key});
+ }
+ close(OLDCONFIG);
+ #
+ # read the hardwired config
+ #
+ # (from file named in $hard_db_config)
+ open(HARDCONFIG,$hard_db_config) || die "Couldn't open $hard_db_config: $!\n";
+ while (<HARDCONFIG>) {
+ chomp;
+ my $key=$_;
+ $key =~ s/ .*//;
+ my $val=$_;
+ $val =~ s/.* //;
+ $running_config{$key}=$val;
+ printf("Read value for %s as %s\n",$key,$running_config{$key});
+ }
+ close(HARDCONFIG);
+ #
+ # read overrides
+ #
+ # (from file named in $imapd_conf)
+ open(IMAPDCONF,$imapd_conf) || die("Couldn't open $imapd_conf: $!\n");
+ while (<IMAPDCONF>) {
+ chomp;
+ my $line = $_;
+ $line =~ s/#.*//;
+ $line =~ s/[[:space:]]{1,}/ /;
+ if (!($line =~ m/^[[:space:]]*$/)) {
+ my $key=$line;
+ $key =~ s/:.*//;
+ my $val=$line;
+ $val =~ s/.*:[[:space:]]*//;
+ # printf("found: $key $val\n");
+ if ( $key eq "annotation_db" ) {
+ #imapd.conf: annotation_db: skiplist
+ #c-d-t.txt: ANNOTATION skiplist
+ $running_config{"ANNOTATION"}=$val;
+ printf("Found ANNOTATION override: %s\n",$val);
+ } elsif ( $key eq "duplicate_db" ) {
+ #imapd.conf: duplicate_db: berkeley-nosync
+ #c-d-t.txt: DUPLICATE berkeley-nosync
+ $running_config{"DUPLICATE"}=$val;
+ printf("Found DUPLICATE override: %s\n",$val);
+ } elsif ( $key eq "mboxlist_db" ) {
+ #imapd.conf: mboxlist_db: skiplist
+ #c-d-t.txt: MBOX skiplist
+ $running_config{"MBOX"}=$val;
+ printf("Found MBOX override: %s\n",$val);
+ } elsif ( $key eq "ptscache_db" ) {
+ #imapd.conf: ptscache_db: berkeley
+ #c-d-t.txt: PTS berkeley
+ $running_config{"PTS"}=$val;
+ printf("Found PTS override: %s\n",$val);
+ } elsif ( $key eq "quota_db" ) {
+ #imapd.conf: quota_db: quotalegacy
+ #c-d-t.txt: QUOTA quotalegacy
+ $running_config{"QUOTA"}=$val;
+ printf("Found QUOTA override: %s\n",$val);
+ } elsif ( $key eq "seenstate_db" ) {
+ #imapd.conf: seenstate_db: skiplist
+ #c-d-t.txt: SEEN skiplist
+ $running_config{"SEEN"}=$val;
+ printf("Found SEEN override: %s\n",$val);
+ } elsif ( $key eq "subscription_db" ) {
+ #imapd.conf: subscription_db: flat
+ #c-d-t.txt: SUBS flat
+ $running_config{"SUBS"}=$val;
+ printf("Found SUBS override: %s\n",$val);
+ } elsif ( $key eq "tlscache_db" ) {
+ #imapd.conf: tlscache_db: berkeley-nosync
+ #c-d-t.txt: TLS berkeley-nosync
+ $running_config{"TLS"}=$val;
+ printf("Found TLS override: %s\n",$val);
+ }
+ }
+ }
+ #
+ # Analyse which database engine is used where
+ #
+ foreach my $i (keys(%running_config)) {
+ if ("DBENGINE" ne $i) {
+ my $val = $running_config{$i};
+ if (defined($used_types{$val})) {
+ $used_types{$val} .= ",$i";
+ } else {
+ $used_types{$val} = $i;
+ }
+ }
+ }
+ foreach my $i (keys(%used_types)) {
+ printf("Database type %s used in: %s\n",$i,$used_types{$i});
+ }
+}
+
+sub usage {
+ printf("Usage: cyrus-db-type-check {check|dump}\n");
+ printf(" check checks wether last running config and current config\n");
+ printf(" are compatible\n");
+ printf(" dump dumps the current config in a format suitable for\n");
+ printf(" /usr/lib/cyrus/cyrus-db-types.active\n");
+ exit 1;
+}
+
+if ( $#ARGV != 0 ) {
+ usage;
+} elsif ($ARGV[0] eq "check") {
+ readconfigs();
+} elsif ($ARGV[0] eq "dump") {
+ readconfigs();
+} else {
+ usage;
+}
+
+__END__
+DBENGINE BerkeleyDB4.2
Propchange: branches/cyrus-db-type-check
------------------------------------------------------------------------------
svn:executable = *
More information about the Pkg-Cyrus-imapd-Debian-devel
mailing list