From 8577c9dbd7a4910ad4403f36d1ad40e0a593e459 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 18 Oct 2011 08:19:08 +0000 Subject: [PATCH] updatefhem backup by RueBe git-svn-id: https://svn.fhem.de/fhem/trunk@1078 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/99_SUNRISE_EL.pm | 1 + fhem/FHEM/99_updatefhem.pm | 37 ++++++++++++++++++ fhem/docs/commandref.html | 78 ++++++++++++++++++++++++++------------ fhem/fhem.pl | 4 +- 4 files changed, 94 insertions(+), 26 deletions(-) diff --git a/fhem/FHEM/99_SUNRISE_EL.pm b/fhem/FHEM/99_SUNRISE_EL.pm index fa5b5bb94..4d671894e 100755 --- a/fhem/FHEM/99_SUNRISE_EL.pm +++ b/fhem/FHEM/99_SUNRISE_EL.pm @@ -33,6 +33,7 @@ sub SUNRISE_EL_Initialize($) { my ($hash) = @_; + $modules{Global}{AttrList} .= " latitude longitude"; } diff --git a/fhem/FHEM/99_updatefhem.pm b/fhem/FHEM/99_updatefhem.pm index c0c741101..cbc55dd36 100644 --- a/fhem/FHEM/99_updatefhem.pm +++ b/fhem/FHEM/99_updatefhem.pm @@ -23,6 +23,8 @@ updatefhem_Initialize($$) my %chash = ( Fn=>"CommandCULflash", Hlp=>" ,flash the CUL from the nightly CVS" ); $cmds{CULflash} = \%chash; + + $modules{Global}{AttrList} .= " backupdir"; } @@ -36,6 +38,41 @@ CommandUpdatefhem($$) my $moddir = "$attr{global}{modpath}/FHEM"; #my $moddir = "XXX"; + ## backup by RueBe + my @commandchain = split(/ +/,$param); + + # Check if the first parameter is "backup" + if(uc($commandchain[0]) eq "BACKUP") { + my $backupdir = AttrVal("global", "backupdir", "/tmp/FHEM_Backup"); + # create the backupfolder + if(!-d $backupdir) { + if(!mkdir($backupdir)) { + return "Can't create backup folder $!"; + } + } + # full backup, for compatibility, we use the native copy unction, not + # dircopy from File::Copy::Recursive + if($commandchain[1] eq "") { + opendir(IMD, $moddir) || return "Cannot open fhem-module directory"; + my @files= readdir(IMD); + closedir(IMD); + my $f; + + foreach $f (@files) { + unless ( ($f eq ".") || ($f eq "..") ) { + my $ret = copy("$moddir/$f", "$backupdir/$f"); + } + } + $param = ""; + + } else { + # one file backup + copy("$moddir/$commandchain[1]", "$backupdir/$commandchain[1]"); + # recreate $param for further use + $param = $commandchain[1]; + } + } + # Read in the OLD filetimes.txt my %oldtime; if(open FH, "$moddir/$ftime") { diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index c0f06cbc3..5d102c3bf 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -548,7 +548,7 @@ A line ending with \ will be concatenated with the next one, so long lines

updatefhem

@@ -925,13 +947,6 @@ A line ending with \ will be concatenated with the next one, so long lines the INITIALIZED event to execute commands after initialization.
- -
  • latitude
    - If set, this latitude is used to calculate sunset/sunrise
    - Notation need to be in decimal format (for example Berlin = 52.666) - As default Frankfurt/Main, Germany (50.112) is used. -

  • -
  • logfile
    Specify the logfile to write. You can use "-" for @@ -940,13 +955,6 @@ A line ending with \ will be concatenated with the next one, so long lines see the FileLog section.

  • -
  • modpath
    Specify the path to the modules directory FHEM. The path @@ -3071,10 +3079,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • desired-temp <value>
    Use the builtin PI regulator, and set the desired temperature to the specified degree. The actual value will be taken from the temperature - reported by the MD15.
  • -
  • desired+actual <value1> <value2>
    - Use the builtin PI regulator, and set the desired temperature to - <value1>. The actual value is supplied in <value2>
  • + reported by the MD15 or from the attribute actualTemp if it is set
  • unattended
    Do not regulate the MD15.
  • @@ -3126,6 +3131,11 @@ A line ending with \ will be concatenated with the next one, so long lines
  • showtime
  • model
  • subType
  • +
  • actualTemp
    + The value of the actual temperature, used when controlling MD15 devices. + Should by filled via a notify from a distinct temperature sensor. If + absent, the reported temperature from the MD15 is used. +

  • @@ -7472,10 +7482,10 @@ sunrise_rel, sunset_rel sunrise_abs, sunset_abs isday perl functions, to be used in at or FS20 on-till commands.
    - First you should edit SUNRISE_EL.pm, and set long and lat to the exact longitude - and latitude values (see e.g. maps.google.com for the exact values, which - should be in the form of a floating point value). The default value is - Frankfurt am Main, Germany. + First you should set the longitude and latitude global attributes to the + exact longitude and latitude values (see e.g. maps.google.com for the exact + values, which should be in the form of a floating point value). The default + value is Frankfurt am Main, Germany.

    The default altitude ($altit in SUNRISE_EL.pm) defines the sunrise/sunset for Civil twilight (i.e. one can no longer read outside without artificial @@ -7509,7 +7519,27 @@ isday Get
    - Attributes
    + Attributes
    + + diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 83d37088f..11d13b629 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -167,7 +167,7 @@ my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my %duplicate; # Pool of received msg for multi-fhz/cul setups my $duplidx=0; # helper for the above pool -my $cvsid = '$Id: fhem.pl,v 1.155 2011-10-16 07:55:20 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.156 2011-10-18 08:19:07 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -185,7 +185,7 @@ $modules{Global}{AttrList} = "archivecmd allowfrom archivedir configfile lastinclude logfile " . "modpath nrarchive pidfilename port statefile title userattr " . "verbose:1,2,3,4,5 mseclog version nofork logdir holiday2we " . - "autoload_undefined_devices dupTimeout latitude longitude"; + "autoload_undefined_devices dupTimeout"; $modules{Global}{AttrFn} = "GlobalAttr"; my $commonAttr = "eventMap";