mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
update rewritten, restore added
git-svn-id: https://svn.fhem.de/fhem/trunk@6421 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4608bfd3c5
commit
f1f68d6e6b
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: update rewritten, restore added
|
||||
- feature: enabled JavaScript in 02_RSS to support WebViewControl
|
||||
- added: new module 36_WMBUS.pm (kaihs) Wireless M-Bus
|
||||
- feature: SYSMON: aded new plots (power infos for cubietruck)
|
||||
|
@ -217,7 +217,7 @@ CommandFheminfo($$)
|
||||
$ret = $str;
|
||||
|
||||
if(@args != 0 && $args[0] eq "send") {
|
||||
my $uri = "http://fhem.de/stats/statistics.cgi";
|
||||
my $uri = "http://fhem.de/stats/statistics.html";
|
||||
my $req = HTTP::Request->new("POST",$uri);
|
||||
$req->content_type("application/x-www-form-urlencoded");
|
||||
my $contInfo;
|
||||
@ -410,7 +410,7 @@ sub _myDiv($$) {
|
||||
The optional parameter <code>send</code> transmitts the collected data
|
||||
to a central server in order to support the development of FHEM. The
|
||||
transmitted data is processed graphically. The results can be viewed
|
||||
on <a href="http://fhem.de/stats/statistics.cgi">http://fhem.de/stats/statistics.cgi</a>.
|
||||
on <a href="http://fhem.de/stats/statistics.html">http://fhem.de/stats/statistics.html</a>.
|
||||
Based on the IP address, the approximate location is determined with
|
||||
an accuracy of about 40-80 km. The IP address is not saved.
|
||||
<br>
|
||||
@ -530,7 +530,7 @@ sub _myDiv($$) {
|
||||
Der optionale Parameter <code>send</code> überträgt die Informationen
|
||||
an einen zentralen Server um die Entwicklung von FHEM zu unterstützen.
|
||||
Die übermittelten Daten werden grafisch aufbereitet und können auf
|
||||
<a href="http://fhem.de/stats/statistics.cgi">http://fhem.de/stats/statistics.cgi</a>
|
||||
<a href="http://fhem.de/stats/statistics.html">http://fhem.de/stats/statistics.html</a>
|
||||
abgerufen werden. Anhand der IP-Adresse wird der ungefähre Standort mit
|
||||
einer Genauigkeit von ca. 40-80 km ermittelt. Die IP-Adresse wird nicht gespeichert.
|
||||
<br>
|
||||
|
123
fhem/FHEM/98_restore.pm
Normal file
123
fhem/FHEM/98_restore.pm
Normal file
@ -0,0 +1,123 @@
|
||||
################################################################
|
||||
# $Id$
|
||||
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Copy qw(cp);
|
||||
|
||||
sub CommandUpdate($$);
|
||||
sub restoreFile($$);
|
||||
sub restoreDir($$);
|
||||
|
||||
########################################
|
||||
sub
|
||||
restore_Initialize($$)
|
||||
{
|
||||
my %hash = (
|
||||
Fn => "CommandRestore",
|
||||
Hlp => "[list] [<filename|directory>],restore files saved by update",
|
||||
);
|
||||
$cmds{restore} = \%hash;
|
||||
}
|
||||
|
||||
########################################
|
||||
sub
|
||||
CommandRestore($$)
|
||||
{
|
||||
my ($cl,$param) = @_;
|
||||
my @args = split(/ +/,$param);
|
||||
my $list = (@args > 0 && $args[0] eq "list");
|
||||
shift @args if($list);
|
||||
my $filename = shift @args;
|
||||
my $dest = $attr{global}{modpath};
|
||||
my $src = "$dest/restoreDir";
|
||||
|
||||
$list = 1 if(!$list && !$filename);
|
||||
return "Usage: restore [list] filename|directory"
|
||||
if(@args);
|
||||
|
||||
$filename = "" if(!$filename);
|
||||
$filename =~ s/\.\.//g;
|
||||
|
||||
return "restoreDir is not yet created" if(!-d $src);
|
||||
return "list argument must be a directory" if($list && !-d "$src/$filename");
|
||||
if($list) {
|
||||
my $dh;
|
||||
opendir($dh, "$src/$filename") || return "opendir $src/$filename: $!";
|
||||
my @files = readdir($dh);
|
||||
closedir($dh);
|
||||
return "Available for restore".($filename ? " in $filename":"").":\n ".
|
||||
join("\n ", sort grep { $_ ne "." && $_ ne ".." } @files);
|
||||
}
|
||||
|
||||
return "$filename is not available for restore" if(!-e "$src/$filename");
|
||||
|
||||
$filename .= "/" if($filename !~ m,/,); # needed for the regexp below
|
||||
$filename =~ m,^([^/]*)/(.*)$,;
|
||||
$src = "$src/$filename";
|
||||
$dest = "$dest/$2" if($2);
|
||||
|
||||
return (-f $src ? restoreFile($src, $dest) : restoreDir($src, $dest));
|
||||
}
|
||||
|
||||
sub
|
||||
restoreFile($$)
|
||||
{
|
||||
my ($src, $dest) = @_;
|
||||
cp($src, $dest) || return "cp $src $dest failed: $!";
|
||||
return "restore $dest";
|
||||
}
|
||||
|
||||
sub
|
||||
restoreDir($$)
|
||||
{
|
||||
my ($src, $dest, $dh, @ret) = @_;
|
||||
opendir($dh, $src) || return "opendir $src: $!";
|
||||
my @files = sort grep { $_ ne "." && $_ ne ".." } readdir($dh);
|
||||
closedir($dh);
|
||||
foreach my $f (@files){
|
||||
if(-d "$src/$f") {
|
||||
push @ret, restoreDir("$src/$f", "$dest/$f");
|
||||
} else {
|
||||
push @ret, restoreFile("$src/$f", "$dest/$f");
|
||||
}
|
||||
}
|
||||
return join("\n", @ret);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
=begin html
|
||||
|
||||
<a name="restore"></a>
|
||||
<h3>restore</h3>
|
||||
<ul>
|
||||
<code>restore list [<filename|directory>]<br>
|
||||
restore [<filename|directory>]</code>
|
||||
<br><br>
|
||||
Restore the files saved previously by the update command. Check the available
|
||||
files with the list argument. See also the update command and its restoreDirs
|
||||
attribute. After a restore normally a "shutdown restart" is necessary.
|
||||
</ul>
|
||||
|
||||
=end html
|
||||
=begin html_DE
|
||||
|
||||
<a name="restore"></a>
|
||||
<h3>restore</h3>
|
||||
<ul>
|
||||
<code>restore list [<filename|directory>]<br>
|
||||
restore <filename|directory></code>
|
||||
<br><br>
|
||||
Restauriert die beim update gesicherten Dateien. Mit dem Argument list kann
|
||||
man die Liste der verf&ügbaeren Sicherungen anzeigen, und mit der Angabe
|
||||
der direkten Datei/Verzeichnis kann man das zurücksichern anstossen.
|
||||
Siehe auch das update Befehl, bzw. das restoreDirs Attribut.
|
||||
Nach restore ist meistens ein "shutdown restart" notwendig.
|
||||
</ul>
|
||||
|
||||
|
||||
=end html_DE
|
||||
=cut
|
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,7 @@
|
||||
<a href="#quit">quit</a>
|
||||
<a href="#reload">reload</a>
|
||||
<a href="#rename">rename</a>
|
||||
<a href="#restore">restore</a>
|
||||
<a href="#rereadcfg">rereadcfg</a>
|
||||
<a href="#save">save</a>
|
||||
<a href="#set">set</a>
|
||||
@ -1103,27 +1104,6 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
receiving a corresponding message.
|
||||
</li><br>
|
||||
|
||||
<a name="updateInBackground"></a>
|
||||
<li>updateInBackground<br>
|
||||
If this attribute is set to 1, the update will be executed in the
|
||||
backgrund process. The return message is communicated via events, and
|
||||
in telnet the inform command is activated, in FHEMWEB the Event
|
||||
Monitor.
|
||||
</li><br>
|
||||
|
||||
<a name="backup_before_update"></a>
|
||||
<li>backup_before_update<br>
|
||||
If this attribute is set to 0, an update skip always backing up your
|
||||
installation via the <a href="#backup">backup</a> command. The default
|
||||
is to backup always before updates.<br>
|
||||
Note: Set this attribute only if you know what you do!<br>
|
||||
This Attribute is used by the <a href="#update">update</a> command.<br>
|
||||
Example:<br>
|
||||
<ul>
|
||||
attr global backup_before_update 0
|
||||
</ul>
|
||||
</li><br>
|
||||
|
||||
<a name="backupcmd"></a>
|
||||
<li>backupcmd<br>
|
||||
You could pass the backup to your own command / script by using this attribute.
|
||||
@ -1174,16 +1154,6 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
be written to this file.
|
||||
</li><br>
|
||||
|
||||
<a name="exclude_from_update"></a>
|
||||
<li>exclude_from_update<br>
|
||||
Contains a space separated list of file which will be excluded by an update.
|
||||
This Attribute is used by the <a href="#update">update</a> command.<br>
|
||||
Example:<br>
|
||||
<ul>
|
||||
attr global exclude_from_update 21_OWTEMP.pm temp4hum4.gplot FS20.on.png FS20.off.png
|
||||
</ul>
|
||||
</li><br>
|
||||
|
||||
<a name="holiday2we"></a>
|
||||
<li>holiday2we<br>
|
||||
If this attribute is set, then the <a href="#perl">$we</a> variable
|
||||
@ -1275,25 +1245,6 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
|
||||
<li><a href="#fheminfo">uniqueID</a>
|
||||
|
||||
<a name="updatebranch"></a>
|
||||
<li>updatebranch<br>
|
||||
The update branch will be set by the file FhemUtils/release.pm contained
|
||||
in the modpath. For example, if a stable version (version 5.3 upwards) of
|
||||
fhem is installed via a direct download connection of the archieve on the
|
||||
fhem-website, then the branch of the update is automatically on "stable".
|
||||
In this branch, only updates fixing confirmed errors, relevant security
|
||||
fixes or new stable versions are provided.<br>
|
||||
By using the command "update development <filename>", particular files
|
||||
or packages can always be installed directly from the development branch
|
||||
(e.g. "update development <package>").<br>
|
||||
If you want to update from the development branch in stable verion in
|
||||
general, you can force this behaviour by using the attribute "updatebranch DEVELOPMENT".
|
||||
In case the installation of fhem should generally using the development
|
||||
branch, this attribute would not have to be set. Instead, use "update development force"
|
||||
to update all files including release.pm (containing the release-information)
|
||||
to the newest version.
|
||||
</li><br>
|
||||
|
||||
<a name="userattr"></a>
|
||||
<li>userattr<br>
|
||||
A space separated list which contains the names of additional
|
||||
|
@ -60,6 +60,7 @@
|
||||
<a href="#reload">reload</a>
|
||||
<a href="#rename">rename</a>
|
||||
<a href="#rereadcfg">rereadcfg</a>
|
||||
<a href="#restore">restore</a>
|
||||
<a href="#save">save</a>
|
||||
<a href="#set">set</a>
|
||||
<a href="#setdefaultattr">setdefaultattr</a>
|
||||
@ -1159,28 +1160,6 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
Nachricht zu erstellen.
|
||||
</li><br>
|
||||
|
||||
<a name="updateInBackground"></a>
|
||||
<li>updateInBackground<br>
|
||||
wenn dieses Attribut gesetzt ist, wird das update Befehl in einem
|
||||
separaten Prozess ausgeführt, und alle Meldungen werden per Event
|
||||
übermittelt. In der telnet Sitzung wird inform, in FHEMWEB wird
|
||||
das Event Monitor aktiviert.
|
||||
</li><br>
|
||||
|
||||
<a name="backup_before_update"></a>
|
||||
<li>backup_before_update<br>
|
||||
Wenn dieses Attribut auf "0" gesetzt wurde, erstellt FHEM keine
|
||||
Sicherheitskopie Ihrer Installation bei Verwendung des Befehls <a href="#backup">backup</a>.
|
||||
Die Standardeinstellung ist die Erstellung einer Sicherheitskopie vor einem
|
||||
Update.<br>
|
||||
Hinweis: Setzen Sie dieses Attribut nur wenn Sie sich sicher sind!<br>
|
||||
Das Attribut wird vom <a href="#update">update</a> Befehl benutzt.<br>
|
||||
Beispiel:<br>
|
||||
<ul>
|
||||
attr global backup_before_update 0
|
||||
</ul>
|
||||
</li><br>
|
||||
|
||||
<a name="backupcmd"></a>
|
||||
<li>backupcmd<br>
|
||||
Sie können das Update durch Ihre eigenen Befehle/Skripts durchführen
|
||||
@ -1234,17 +1213,6 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
Dateinamen gespeichert.
|
||||
</li><br>
|
||||
|
||||
<a name="exclude_from_update"></a>
|
||||
<li>exclude_from_update<br>
|
||||
Enthält eine Liste durch Leerzeichen getrennter Dateien welche nicht im
|
||||
Update berücksichtigt werden. Dieses Attribut wird vom <a href="#update">update</a>
|
||||
Befehl benutzt.<br>
|
||||
Beispiel:<br>
|
||||
<ul>
|
||||
attr global exclude_from_update 21_OWTEMP.pm temp4hum4.gplot FS20.on.png FS20.off.png
|
||||
</ul>
|
||||
</li><br>
|
||||
|
||||
<a name="holiday2we"></a>
|
||||
<li>holiday2we<br>
|
||||
Wenn dieses Attribut gesetzt wurde, dann wird die <a href="#perl">$we</a>
|
||||
|
@ -244,7 +244,7 @@ $modules{Global}{AttrList} =
|
||||
"mseclog:1,0 version nofork:1,0 logdir holiday2we " .
|
||||
"autoload_undefined_devices:1,0 dupTimeout latitude longitude altitude " .
|
||||
"backupcmd backupdir backupsymlink backup_before_update " .
|
||||
"exclude_from_update motd updatebranch uniqueID ".
|
||||
"exclude_from_update motd restoreDirs uniqueID ".
|
||||
"sendStatistics:onUpdate,manually,never updateInBackground:1,0 ".
|
||||
"showInternalValues:1,0 ";
|
||||
$modules{Global}{AttrFn} = "GlobalAttr";
|
||||
|
Loading…
Reference in New Issue
Block a user