mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
fhem.pl: change motd handlig (Forum #110097)
git-svn-id: https://svn.fhem.de/fhem/trunk@21647 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9b2f92a8df
commit
38962ff746
@ -1165,9 +1165,10 @@ FW_answerCall($)
|
||||
$srVal = FW_showRoom();
|
||||
|
||||
} else {
|
||||
my $motd = AttrVal("global","motd","none");
|
||||
if($motd ne "none") {
|
||||
FW_addContent("><pre class='motd'>$motd</pre></div");
|
||||
my $motd = AttrVal("global", "motd", "");
|
||||
my $gie = $defs{global}{init_errors};
|
||||
if($motd ne "none" && ($motd || $gie)) {
|
||||
FW_addContent("><pre class='motd'>$motd\n$gie</pre></div");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,8 +258,11 @@ telnet_Read($)
|
||||
} else {
|
||||
$hash->{showPrompt} = 1; # Empty return
|
||||
if(!$hash->{motdDisplayed}) {
|
||||
my $motd = $attr{global}{motd};
|
||||
push @ret, $motd if($motd && $motd ne "none");
|
||||
my $motd = AttrVal("global", "motd", "");
|
||||
my $gie = $defs{global}{init_errors};
|
||||
if($motd ne "none" && ($motd || $gie)) {
|
||||
push @ret, "$motd\n$gie";
|
||||
}
|
||||
$hash->{motdDisplayed} = 1;
|
||||
}
|
||||
}
|
||||
|
33
fhem/fhem.pl
33
fhem/fhem.pl
@ -600,15 +600,14 @@ if(gettimeofday() < 2*3600) {
|
||||
require RTypes;
|
||||
RTypes_Initialize();
|
||||
|
||||
my $cfgErrMsg = "Messages collected while initializing FHEM:";
|
||||
my $cfgRet="";
|
||||
$defs{global}{init_errors}="";
|
||||
if(configDBUsed()) {
|
||||
my $ret = cfgDB_ReadAll(undef);
|
||||
$cfgRet .= "configDB: $ret\n" if($ret);
|
||||
$defs{global}{init_errors} .= "configDB: $ret\n" if($ret);
|
||||
|
||||
} else {
|
||||
my $ret = CommandInclude(undef, $attr{global}{configfile});
|
||||
$cfgRet .= "configfile: $ret\n" if($ret);
|
||||
$defs{global}{init_errors} .= "configfile: $ret\n" if($ret);
|
||||
|
||||
my $stateFile = $attr{global}{statefile};
|
||||
if($stateFile) {
|
||||
@ -616,7 +615,7 @@ if(configDBUsed()) {
|
||||
$stateFile = ResolveDateWildcards($stateFile, @t);
|
||||
if(-r $stateFile) {
|
||||
$ret = CommandInclude(undef, $stateFile);
|
||||
$cfgRet .= "$stateFile: $ret\n" if($ret);
|
||||
$defs{global}{init_errors} .= "$stateFile: $ret\n" if($ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -644,17 +643,14 @@ foreach my $d (keys %defs) {
|
||||
}
|
||||
}
|
||||
|
||||
if($cfgRet) {
|
||||
$attr{global}{autosave} = 0;
|
||||
$attr{global}{motd} = "$cfgErrMsg\n$cfgRet\nAutosave deactivated";
|
||||
Log 1, $cfgRet;
|
||||
|
||||
} elsif($attr{global}{motd} && $attr{global}{motd} =~ m/^$cfgErrMsg/) {
|
||||
$attr{global}{motd} = "";
|
||||
|
||||
} else {
|
||||
SecurityCheck();
|
||||
|
||||
my $init_errors_first = ($defs{global}{init_errors} ? 1 : 0);
|
||||
SecurityCheck();
|
||||
if($defs{global}{init_errors}) {
|
||||
$attr{global}{autosave} = 0 if($init_errors_first);
|
||||
$defs{global}{init_errors} = "Messages collected while initializing FHEM:".
|
||||
"$defs{global}{init_errors}\n".
|
||||
($init_errors_first ? "Autosave deactivated" : "");
|
||||
Log 1, $defs{global}{init_errors} if(AttrVal("global","motd","") ne "none");
|
||||
}
|
||||
|
||||
|
||||
@ -5976,7 +5972,6 @@ restoreDir_saveFile($$)
|
||||
sub
|
||||
SecurityCheck()
|
||||
{
|
||||
return if(AttrVal("global", "motd", "") eq "none");
|
||||
my @fnd;
|
||||
foreach my $sdev (keys %defs) {
|
||||
next if($defs{$sdev}{TEMPORARY});
|
||||
@ -6005,9 +6000,7 @@ SecurityCheck()
|
||||
if(@fnd) {
|
||||
unshift(@fnd, "SecurityCheck:");
|
||||
push(@fnd, "You can disable this message with attr global motd none");
|
||||
$attr{global}{motd} = join("\n", @fnd);
|
||||
} elsif(AttrVal('global','motd','') =~ m/^SecurityCheck/) {
|
||||
delete $attr{global}{motd};
|
||||
$defs{global}{init_errors} .= join("\n", @fnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user