X-Git-Url: http://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=onak-mail.pl.in;h=2083042e86d716ba7bc19fb7c93b599489c4d787;hp=097404e67b6a9df44761bfbb5ff1d15748ecb712;hb=76f079e5ebdb34acaaa2462a8d915ee06d3c8425;hpb=a183a1f43e77bc96119f60a5b056dd0a489eabe2 diff --git a/onak-mail.pl.in b/onak-mail.pl.in index 097404e..2083042 100644 --- a/onak-mail.pl.in +++ b/onak-mail.pl.in @@ -14,14 +14,14 @@ use IPC::Open3; my %config; # -# readconfig +# readoldconfig # -# 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. +# Read an old pksd-style config file. Currently if both old and new style +# files are present the old style will be preferred in order to ensure smooth +# upgrades. # -sub readconfig { - - open(CONFIG, "@CONFIG@") or +sub readoldconfig { + open(CONFIG, "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.conf") or die "Can't read config file: $!"; while () { @@ -49,6 +49,54 @@ sub readconfig { return; } +# +# 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 { + # Prefer the old style config if it exists. + if (-e "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.conf") { + &readoldconfig; + return; + } + + open(CONFIG, "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.ini") or + die "Can't read config file: $!"; + + my $section = ""; + while () { + if (/^#/ or /^$/) { + # Ignore; comment line. + } elsif (/^\[(\w+)\]/) { + $section = $1; + } elsif ($section eq "main") { + if (/^logfile\s*=\s*(.*)/) { + $config{'logfile'} = $1; + } + } elsif ($section eq "mail") { + if (/^this_site\s*=\s*(.*)/) { + $config{'thissite'} = $1; + } elsif (/^maintainer_email\s*=\s*(.*)/) { + $config{'adminemail'} = $1; + } elsif (/^mta\s*=\s*(.*)/) { + $config{'mta'} = $1; + } elsif (/^bin_dir\s*=\s*(.*)/) { + $config{'pks_bin_dir'} = $1; + } elsif (/^mail_dir\s*=\s*(.*)/) { + $config{'mail_dir'} = $1; + } elsif (/^syncsite\s*=\s*(.*)/) { + push @{$config{'syncsites'}}, $1; + } + } + } + + close(CONFIG); + + return; +} + # # submitupdate #