cscvs to tla changeset 29
[onak.git] / onak-mail.pl
index 30e5b9326034e96686ef76f5e2f11acf63bd065d..0e3c2b5b46ba359eb778452339143e21543a160a 100755 (executable)
 use strict;
 use IPC::Open3;
 
+my %config;
+
+#
+# readconfig
+#
+# Reads in our config file. Ignores any command it doesn't understand rather
+# than having to list all the ones that are of no interest to us.
+#
+sub readconfig {
+
+       open(CONFIG, "/home/noodles/projects/onak/onak.conf") or
+               die "Can't read config file: $!";
+       
+       while (<CONFIG>) {
+               if (/^#/ or /^$/) {
+                       # Ignore; comment line.
+               } elsif (/^this_site (.*)/) {
+                       $config{'thissite'} = $1;
+               } elsif (/^maintainer_email (.*)/) {
+                       $config{'adminemail'} = $1;
+               } elsif (/^mail_delivery_client (.*)/) {
+                       $config{'mta'} = $1;
+               } elsif (/^syncsite (.*)/) {
+                       push @{$config{'syncsites'}}, $1;
+               }
+       }
+
+       close(CONFIG);
+
+       return;
+}
+
 #
 # submitupdate
 #
@@ -22,14 +54,17 @@ sub submitupdate {
        my @data = @_;
        my (@errors, @mergedata);
 
-       open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR, "/home/noodles/onak-0.0.2/keymerge");
+       open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR,
+               "/home/noodles/onak-0.0.3/onak", "add");
 
        print MERGEIN @data;
        close MERGEIN;
        @errors = <MERGEERR>;
        @mergedata = <MERGEOUT>;
 
-       #print @errors;
+       open (LOG, ">>/home/noodles/onak-0.0.3/keyadd.log");
+       print LOG @errors;
+       close LOG;
 
        return @mergedata;
 }
@@ -38,6 +73,7 @@ my ($inheader, %syncsites, $subject, $from, $replyto, @body, @syncmail);
 
 $inheader = 1;
 $subject = "";
+&readconfig;
 
 while (<>) {
        if ($inheader) {