From 4fe30a7f0c7d94f4f75532077e6ffa03b221bfbe Mon Sep 17 00:00:00 2001 From: betateilchen <> Date: Mon, 4 Jul 2016 20:02:31 +0000 Subject: [PATCH] configDB.pm: improve reading of config file git-svn-id: https://svn.fhem.de/fhem/trunk@11738 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/configDB.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fhem/configDB.pm b/fhem/configDB.pm index 1701daf31..869d46fa1 100644 --- a/fhem/configDB.pm +++ b/fhem/configDB.pm @@ -116,6 +116,8 @@ # # 2016-07-03 - added support for multiple hosts (experimental) # +# 2016-07-04 - fixed improve config file read +# ############################################################################## # @@ -179,8 +181,16 @@ if(!open(CONFIG, 'configDB.conf')) { Log3('configDB', 1, 'Cannot open database configuration file configDB.conf'); return 0; } -my @config=; -close(CONFIG); +#my @config=; +#close(CONFIG); + +my @config; +while (){ + my $line = $_; + $line =~ s/^\s+|\s+$//g; + push (@config,$line) if($line !~ m/^#/ && length($line) > 0); +} +close CONFIG; use vars qw(%configDB); @@ -197,9 +207,11 @@ my $count = @configs; if ($count > 1) { my $fhemhost = hostname; foreach my $c (@configs) { + next unless $c =~ m/^%dbconfig.*/; eval $c; last if ($dbconfig{fhemhost} eq $fhemhost); } + eval $configs[0] unless (defined($dbconfig{fhemhost}) && length($dbconfig{fhemhost})) } else { eval $configs[0]; }