+#
+# 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 (<CONFIG>) {
+ 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;
+}
+