mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
configDBUsed added (fhem.pl + some modules)
git-svn-id: https://svn.fhem.de/fhem/trunk@5588 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9a82cf589b
commit
86df487df8
@ -1529,7 +1529,7 @@ FW_style($$)
|
|||||||
$attr{global}{configfile} =~ m,([^/]*)$,;
|
$attr{global}{configfile} =~ m,([^/]*)$,;
|
||||||
my $cfgFileName = $1;
|
my $cfgFileName = $1;
|
||||||
FW_displayFileList("config file", $cfgFileName)
|
FW_displayFileList("config file", $cfgFileName)
|
||||||
if($attr{global}{configfile} ne 'configDB');
|
if(!configDBUsed());
|
||||||
FW_displayFileList("Own modules and helper files",
|
FW_displayFileList("Own modules and helper files",
|
||||||
FW_fileList("$MW_dir/^(.*sh|[0-9][0-9].*Util.*pm|.*cfg|.*holiday".
|
FW_fileList("$MW_dir/^(.*sh|[0-9][0-9].*Util.*pm|.*cfg|.*holiday".
|
||||||
"|.*layout)\$"));
|
"|.*layout)\$"));
|
||||||
|
@ -62,7 +62,7 @@ holiday_refresh($$)
|
|||||||
|
|
||||||
my $fname = $attr{global}{modpath} . "/FHEM/" . $hash->{NAME} . ".holiday";
|
my $fname = $attr{global}{modpath} . "/FHEM/" . $hash->{NAME} . ".holiday";
|
||||||
my @holidayfile;
|
my @holidayfile;
|
||||||
if($attr{global}{configfile} eq 'configDB') {
|
if(configDBUsed()) {
|
||||||
my $hfile = _cfgDB_Readfile($fname);
|
my $hfile = _cfgDB_Readfile($fname);
|
||||||
return "Holiday file not found in database." unless defined $hfile;
|
return "Holiday file not found in database." unless defined $hfile;
|
||||||
@holidayfile = split("\n", $hfile);
|
@holidayfile = split("\n", $hfile);
|
||||||
|
@ -54,7 +54,7 @@ CommandBackup($$)
|
|||||||
my $msg;
|
my $msg;
|
||||||
my $ret;
|
my $ret;
|
||||||
|
|
||||||
return "Backup is not supported for configDB" if($configfile eq 'configDB');
|
return "Backup is not supported for configDB" if(configDBUsed());
|
||||||
|
|
||||||
# set backupdir
|
# set backupdir
|
||||||
my $backupdir;
|
my $backupdir;
|
||||||
|
@ -309,7 +309,7 @@ sub checkConfigFile($) {
|
|||||||
my $name = "fheminfo";
|
my $name = "fheminfo";
|
||||||
my $configFile = AttrVal("global","configfile","");
|
my $configFile = AttrVal("global","configfile","");
|
||||||
|
|
||||||
if($configFile && $configFile ne 'configDB') {
|
if($configFile && !configDBUsed()) {
|
||||||
my $fh;
|
my $fh;
|
||||||
if(!open($fh,"<".$configFile)) {
|
if(!open($fh,"<".$configFile)) {
|
||||||
return "Can't open $configFile: $!";
|
return "Can't open $configFile: $!";
|
||||||
|
@ -433,8 +433,7 @@ update_DoUpdate(@)
|
|||||||
|
|
||||||
# do a backup first
|
# do a backup first
|
||||||
my $configfile = AttrVal("global", "configfile", "");
|
my $configfile = AttrVal("global", "configfile", "");
|
||||||
my $doBackup = AttrVal("global", "backup_before_update",
|
my $doBackup = AttrVal("global", "backup_before_update", !configDBUsed());
|
||||||
($configfile ne 'configDB'));
|
|
||||||
|
|
||||||
if ($doBackup) {
|
if ($doBackup) {
|
||||||
my $cmdret = AnalyzeCommand(undef, "backup");
|
my $cmdret = AnalyzeCommand(undef, "backup");
|
||||||
|
20
fhem/fhem.pl
20
fhem/fhem.pl
@ -94,6 +94,7 @@ sub addToWritebuffer($$);
|
|||||||
sub attrSplit($);
|
sub attrSplit($);
|
||||||
sub computeClientArray($$);
|
sub computeClientArray($$);
|
||||||
sub concatc($$$);
|
sub concatc($$$);
|
||||||
|
sub configDBUsed();
|
||||||
sub createInterfaceDefinitions();
|
sub createInterfaceDefinitions();
|
||||||
sub createNtfyHash();
|
sub createNtfyHash();
|
||||||
sub devspec2array($);
|
sub devspec2array($);
|
||||||
@ -402,7 +403,7 @@ $winService ||= {};
|
|||||||
# Server initialization
|
# Server initialization
|
||||||
doGlobalDef($ARGV[0]);
|
doGlobalDef($ARGV[0]);
|
||||||
|
|
||||||
if($attr{global}{configfile} eq 'configDB') {
|
if(configDBUsed()) {
|
||||||
eval "use configDB";
|
eval "use configDB";
|
||||||
Log 1, $@ if($@);
|
Log 1, $@ if($@);
|
||||||
cfgDB_Init();
|
cfgDB_Init();
|
||||||
@ -435,7 +436,7 @@ while(time() < 2*3600) {
|
|||||||
|
|
||||||
my $cfgErrMsg = "Error messages while initializing FHEM:";
|
my $cfgErrMsg = "Error messages while initializing FHEM:";
|
||||||
my $cfgRet="";
|
my $cfgRet="";
|
||||||
if($attr{global}{configfile} eq 'configDB') {
|
if(configDBUsed()) {
|
||||||
my $ret = cfgDB_ReadAll(undef);
|
my $ret = cfgDB_ReadAll(undef);
|
||||||
$cfgRet .= "configDB: $ret" if($ret);
|
$cfgRet .= "configDB: $ret" if($ret);
|
||||||
|
|
||||||
@ -1145,7 +1146,7 @@ CommandRereadCfg($$)
|
|||||||
my $name = ($cl ? $cl->{NAME} : "__anonymous__");
|
my $name = ($cl ? $cl->{NAME} : "__anonymous__");
|
||||||
my $cfgfile = ($param ? $param : $attr{global}{configfile});
|
my $cfgfile = ($param ? $param : $attr{global}{configfile});
|
||||||
return "Cannot open $cfgfile: $!"
|
return "Cannot open $cfgfile: $!"
|
||||||
if(! -f $cfgfile && $attr{global}{configfile} ne 'configDB');
|
if(! -f $cfgfile && !configDBUsed());
|
||||||
|
|
||||||
$attr{global}{configfile} = $cfgfile;
|
$attr{global}{configfile} = $cfgfile;
|
||||||
WriteStatefile();
|
WriteStatefile();
|
||||||
@ -1170,7 +1171,7 @@ CommandRereadCfg($$)
|
|||||||
doGlobalDef($cfgfile);
|
doGlobalDef($cfgfile);
|
||||||
my $ret;
|
my $ret;
|
||||||
|
|
||||||
if($attr{global}{configfile} eq 'configDB') {
|
if(configDBUsed()) {
|
||||||
$ret = cfgDB_ReadAll($cl);
|
$ret = cfgDB_ReadAll($cl);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1210,7 +1211,7 @@ CommandQuit($$)
|
|||||||
sub
|
sub
|
||||||
WriteStatefile()
|
WriteStatefile()
|
||||||
{
|
{
|
||||||
if($attr{global}{configfile} eq 'configDB') {
|
if(configDBUsed()) {
|
||||||
cfgDB_SaveState();
|
cfgDB_SaveState();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -1279,7 +1280,7 @@ CommandSave($$)
|
|||||||
|
|
||||||
WriteStatefile();
|
WriteStatefile();
|
||||||
|
|
||||||
if($attr{global}{configfile} eq 'configDB') {
|
if(configDBUsed()) {
|
||||||
$ret = cfgDB_SaveCfg();
|
$ret = cfgDB_SaveCfg();
|
||||||
return ($ret ? $ret : "Saved configuration to the DB");
|
return ($ret ? $ret : "Saved configuration to the DB");
|
||||||
}
|
}
|
||||||
@ -2400,7 +2401,7 @@ CommandVersion($$)
|
|||||||
my ($cl, $param) = @_;
|
my ($cl, $param) = @_;
|
||||||
|
|
||||||
my @ret = ("# $cvsid");
|
my @ret = ("# $cvsid");
|
||||||
push @ret, cfgDB_svnId if $attr{global}{configfile} eq 'configDB';
|
push @ret, cfgDB_svnId if(configDBUsed());
|
||||||
foreach my $m (sort keys %modules) {
|
foreach my $m (sort keys %modules) {
|
||||||
next if(!$modules{$m}{LOADED} || $modules{$m}{ORDER} < 0);
|
next if(!$modules{$m}{LOADED} || $modules{$m}{ORDER} < 0);
|
||||||
Log 4, "Looking for SVN Id in module $m";
|
Log 4, "Looking for SVN Id in module $m";
|
||||||
@ -3855,5 +3856,10 @@ notifyRegexpChanged($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
configDBUsed()
|
||||||
|
{
|
||||||
|
return ($attr{global}{configfile} eq 'configDB');
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user