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