From 6bc8caa7cc13cf989717ad36051d7532f6a94ca1 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Tue, 9 Oct 2012 19:19:15 +0000
Subject: [PATCH] rereadcfg argument added
git-svn-id: https://svn.fhem.de/fhem/trunk@1942 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/docs/commandref.html | 11 ++++++-----
fhem/fhem.pl | 6 ++++--
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html
index 2c2f6f030..1d0e89d4a 100644
--- a/fhem/docs/commandref.html
+++ b/fhem/docs/commandref.html
@@ -1012,13 +1012,14 @@ A line ending with \ will be concatenated with the next one, so long lines
rereadcfg
- rereadcfg
+ rereadcfg [fhem-config-file]
- Re-read the configuration file.
- Note: The statefile will be saved first, then the config file will be read
+ Re-read the configuration file, or the optionally specified file.
+ The sequence: the statefile will be saved first, then all devices will be
+ deleted, then the original config file (or the specified file) will be read
(all devices will be initialized again), and at last the statefile will be
- reloaded. It triggers upon completion the global:REREADCFG event.
- All existing connections up to the one issuing the rereadcfg will be closed.
+ reloaded. It triggers upon completion the global:REREADCFG event. All
+ existing connections up to the one issuing the rereadcfg will be closed.
Example:
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 23e9ab19e..34162a1e4 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -235,7 +235,7 @@ $modules{Global}{AttrFn} = "GlobalAttr";
"rename" => { Fn=>"CommandRename",
Hlp=>" ,rename a definition" },
"rereadcfg" => { Fn=>"CommandRereadCfg",
- Hlp=>",reread the config file" },
+ Hlp=>"[configfile],read in the config after deleting everything" },
"save" => { Fn=>"CommandSave",
Hlp=>"[configfile],write the configfile and the statefile" },
"set" => { Fn=>"CommandSet",
@@ -882,7 +882,10 @@ CommandRereadCfg($$)
{
my ($cl, $param) = @_;
my $name = $cl->{NAME} if($cl);
+ my $cfgfile = ($param ? $param : $attr{global}{configfile});
+ return "Cannon open $cfgfile: $!" if(! -f $cfgfile);
+ $attr{global}{configfile} = $cfgfile;
WriteStatefile();
$reread_active=1;
@@ -896,7 +899,6 @@ CommandRereadCfg($$)
delete $defs{$d};
}
- my $cfgfile = $attr{global}{configfile};
%comments = ();
%defs = ();
%attr = ();