98_update.pm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. ################################################################
  2. # $Id: 98_update.pm 16551 2018-04-04 18:50:38Z rudolfkoenig $
  3. package main;
  4. use strict;
  5. use warnings;
  6. use HttpUtils;
  7. use File::Copy qw(mv copy);
  8. use Blocking;
  9. sub CommandUpdate($$);
  10. sub upd_getUrl($);
  11. sub upd_initRestoreDirs($);
  12. sub upd_writeFile($$$$);
  13. sub upd_mv($$);
  14. sub upd_metainit($);
  15. sub upd_metacmd($@);
  16. sub upd_saveConfig($$$);
  17. my $updateInBackground;
  18. my $updRet;
  19. my $updArg;
  20. my $mainPgm = "/fhem.pl\$";
  21. my %upd_connecthash;
  22. my $upd_needJoin;
  23. my $upd_nChanged;
  24. my $upd_running;
  25. eval "require IO::Socket::SSL"; # Forum #74387
  26. my $upd_hasSSL = $@ ? 0 : 1;
  27. ########################################
  28. sub
  29. update_Initialize($$)
  30. {
  31. my %hash = (
  32. Fn => "CommandUpdate",
  33. Hlp => "[<fileName>|all|check|checktime|force] [http://.../controlfile],".
  34. "update FHEM",
  35. );
  36. $cmds{update} = \%hash;
  37. }
  38. ########################################
  39. sub
  40. CommandUpdate($$)
  41. {
  42. my ($cl,$param) = @_;
  43. my @args = split(/ +/,$param);
  44. my $err = upd_metainit(0);
  45. return $err if($err);
  46. if($args[0] &&
  47. ($args[0] eq "list" ||
  48. $args[0] eq "add" ||
  49. $args[0] eq "delete" ||
  50. $args[0] eq "reset")) {
  51. return upd_metacmd($cl, @args);
  52. }
  53. my $arg = (defined($args[0]) ? $args[0] : "all");
  54. my $src = (defined($args[1]) ? $args[1] : "");
  55. my $ret = eval { "Hello" =~ m/$arg/ };
  56. return "first argument must be a valid regexp, all, force, check or checktime"
  57. if($arg =~ m/^[-\?\*]/ || $ret);
  58. $arg = lc($arg) if($arg =~ m/^(check|checktime|all|force)$/i);
  59. $updateInBackground = AttrVal("global","updateInBackground",1);
  60. $updateInBackground = 0 if($arg ne "all");
  61. $updArg = $arg;
  62. return "An update is already running" if($upd_running);
  63. $upd_running = 1;
  64. if($updateInBackground) {
  65. CallFn($cl->{NAME}, "ActivateInformFn", $cl, "log");
  66. sub updDone(@) { $upd_running=0 }
  67. BlockingCall("doUpdateInBackground", {src=>$src,arg=>$arg}, "updDone");
  68. return "Executing the update the background.";
  69. } else {
  70. doUpdateLoop($src, $arg);
  71. my $ret = $updRet; $updRet = "";
  72. $upd_running = 0;
  73. return $ret;
  74. }
  75. }
  76. sub
  77. upd_metainit($)
  78. {
  79. my $force = shift;
  80. my $mpath = $attr{global}{modpath}."/FHEM/controls.txt";
  81. if($force || ! -f $mpath || -s $mpath == 0) {
  82. if(!open(FH, ">$mpath")) {
  83. my $msg = "Can't open $mpath: $!";
  84. Log 1, $msg;
  85. return $msg;
  86. }
  87. print FH "http://fhem.de/fhemupdate/controls_fhem.txt\n";
  88. close(FH);
  89. }
  90. return undef;
  91. }
  92. sub
  93. upd_metacmd($@)
  94. {
  95. my ($cl, @args) = @_;
  96. my $mpath = $attr{global}{modpath}."/FHEM/controls.txt";
  97. if($args[0] eq "list") {
  98. open(FH, $mpath) || return "Can't open $mpath: $!";
  99. my $ret = join("", <FH>);
  100. close(FH);
  101. return $ret;
  102. }
  103. if($args[0] eq "add") {
  104. return "Usage: update add http://.../controls_.*.txt"
  105. if(int(@args) != 2 || $args[1] !~ m,^http.*/(controls_.*.txt)$,);
  106. my $fname = $1;
  107. open(FH, $mpath) || return "Can't open $mpath: $!";
  108. my (%fulls, %parts);
  109. map {chomp($_);$fulls{$_}=1; my $x=$_; $x =~ s,^.*/,,; $parts{$x}=$_;} <FH>;
  110. close(FH);
  111. return "$args[1] is already in the list" if($fulls{$args[1]});
  112. return "$fname is already present in $parts{$fname}" if($parts{$fname});
  113. open(FH, ">>$mpath") || return "Can't write $mpath: $!";
  114. print FH $args[1],"\n";
  115. close(FH);
  116. return undef;
  117. }
  118. if($args[0] eq "delete") {
  119. return "Usage: update delete http://.../controls_.*.txt"
  120. if(int(@args) != 2 || $args[1] !~ m,^http.*/(controls_.*.txt)$,);
  121. open(FH, $mpath) || return "Can't open $mpath: $!";
  122. my @list = grep { $_ ne $args[1]."\n"; } <FH>;
  123. close(FH);
  124. open(FH, ">$mpath") || return "Can't write $mpath: $!";
  125. print FH join("", @list);
  126. close(FH);
  127. return undef;
  128. }
  129. if($args[0] eq "reset") {
  130. return upd_metainit(1);
  131. }
  132. }
  133. sub
  134. uLog($$)
  135. {
  136. my ($loglevel, $arg) = @_;
  137. return if($loglevel > $attr{global}{verbose} || !defined($arg));
  138. if($updateInBackground) {
  139. Log 1, $arg;
  140. } else {
  141. Log $loglevel, $arg if($updArg ne "check" && $updArg ne "checktime");
  142. $updRet .= "$arg\n";
  143. }
  144. }
  145. my $inLog = 0;
  146. sub
  147. update_Log2Event($$)
  148. {
  149. my ($level, $text) = @_;
  150. return if($inLog || $level > $attr{global}{verbose});
  151. $inLog = 1;
  152. $text =~ s/\n/ /g; # Multiline text causes havoc in Analyze
  153. BlockingInformParent("Log", [$level, $text], 0);
  154. $inLog = 0;
  155. }
  156. sub
  157. doUpdateInBackground($)
  158. {
  159. my ($h) = @_;
  160. no warnings 'redefine'; # The main process is not affected
  161. *Log = \&update_Log2Event;
  162. sleep(2); # Give time for ActivateInform / FHEMWEB / JavaScript
  163. doUpdateLoop($h->{src}, $h->{arg});
  164. }
  165. sub
  166. doUpdateLoop($$)
  167. {
  168. my ($src, $arg) = @_;
  169. $upd_needJoin = 0;
  170. $upd_nChanged = 0;
  171. if($src =~ m/^http.*/) {
  172. doUpdate(1,1, $src, $arg);
  173. HttpUtils_Close(\%upd_connecthash);
  174. return;
  175. }
  176. my $mpath = $attr{global}{modpath}."/FHEM/controls.txt";
  177. if(!open(LFH, $mpath)) {
  178. my $msg = "Can't open $mpath: $!";
  179. uLog 1, $msg;
  180. return $msg;
  181. }
  182. my @list = <LFH>;
  183. close(LFH);
  184. chomp @list;
  185. my ($max,$curr) = (0,0);
  186. foreach my $srcLine (@list) {
  187. next if($src && $srcLine !~ m/controls_${src}.txt/);
  188. $max++;
  189. }
  190. uLog 1, "No source file named controls_$src found" if($src && !$max);
  191. foreach my $srcLine (@list) {
  192. next if($src && $srcLine !~ m/controls_${src}.txt/);
  193. doUpdate(++$curr, $max, $srcLine, $arg);
  194. HttpUtils_Close(\%upd_connecthash);
  195. }
  196. if($upd_nChanged) {
  197. if($updateInBackground) {
  198. BlockingInformParent("DoTrigger", ["global", "UPDATE", 0 ], 0)
  199. } else {
  200. DoTrigger("global","UPDATE", 0);
  201. }
  202. }
  203. }
  204. sub
  205. doUpdate($$$$)
  206. {
  207. my ($curr, $max, $src, $arg) = @_;
  208. my ($basePath, $ctrlFileName);
  209. $src =~ s'^http://fhem\.de'https://fhem.de' if($upd_hasSSL);
  210. if($src !~ m,^(.*)/([^/]*)$,) {
  211. uLog 1, "Cannot parse $src, probably not a valid http control file";
  212. return;
  213. }
  214. $basePath = $1;
  215. $ctrlFileName = $2;
  216. $ctrlFileName =~ m/controls_(.*).txt/;
  217. my $srcName = $1;
  218. my $isCheck = ($arg eq "check" || $arg eq "checktime");
  219. if(AttrVal("global", "backup_before_update", 0) &&
  220. !$isCheck && $curr==1) {
  221. my $cmdret = AnalyzeCommand(undef, "backup startedByUpdate");
  222. if ($cmdret !~ m/backup done.*/) {
  223. uLog 1, "Something went wrong during backup: $cmdret";
  224. uLog 1, "update was canceled. Please check manually!";
  225. return;
  226. }
  227. }
  228. if($max != 1) {
  229. uLog 1, "";
  230. uLog 1, $srcName;
  231. }
  232. my $remCtrlFile = upd_getUrl($src);
  233. return if(!$remCtrlFile);
  234. my @remList = split(/\R/, $remCtrlFile);
  235. uLog 4, "Got remote $ctrlFileName with ".int(@remList)." entries.";
  236. ###########################
  237. # read in & digest the local control file
  238. my $root = $attr{global}{modpath};
  239. my $restoreDir = ($isCheck ? "" : restoreDir_init("update"));
  240. my @locList;
  241. if(($isCheck || $arg eq "all") &&
  242. open(FD, "$root/FHEM/$ctrlFileName")) {
  243. @locList = map { $_ =~ s/[\r\n]//; $_ } <FD>;
  244. close(FD);
  245. uLog 4, "Got local $ctrlFileName with ".int(@locList)." entries.";
  246. }
  247. my %lh;
  248. foreach my $l (@locList) {
  249. my @l = split(" ", $l, 4);
  250. next if($l[0] ne "UPD");
  251. $lh{$l[3]}{TS} = $l[1];
  252. $lh{$l[3]}{LEN} = $l[2];
  253. }
  254. my $canJoin;
  255. my $cmod = AttrVal('global', 'commandref', 'full');
  256. my $cj = "$root/contrib/commandref_".
  257. ($cmod eq "full" ? "join":"modular").".pl";
  258. if(-f $cj &&
  259. -f "$root/docs/commandref_frame.html" &&
  260. -w "$root/docs/commandref.html" &&
  261. (AttrVal('global','exclude_from_update','') !~ m/commandref/) ) {
  262. $canJoin = 1;
  263. }
  264. my @excl = split(" ", AttrVal("global", "exclude_from_update", ""));
  265. my $noSzCheck = AttrVal("global", "updateNoFileCheck", configDBUsed());
  266. my @rl = upd_getChanges($root, $basePath);
  267. ###########################
  268. # process the remote controlfile
  269. my ($nChanged,$nSkipped) = (0,0);
  270. my $isSingle = ($arg ne "all" && $arg ne "force" && !$isCheck);
  271. foreach my $r (@remList) {
  272. my @r = split(" ", $r, 4);
  273. if($r[0] eq "MOV" && ($arg eq "all" || $arg eq "force")) {
  274. if($r[1] =~ m+\.\.+ || $r[2] =~ m+\.\.+) {
  275. uLog 1, "Suspicious line $r, aborting";
  276. return 1;
  277. }
  278. restoreDir_mkDir($root, $r[2], 0);
  279. my $mvret = upd_mv("$root/$r[1]", "$root/$r[2]");
  280. uLog 4, "mv $root/$r[1] $root/$r[2]". ($mvret ? " FAILED:$mvret":"");
  281. }
  282. next if($r[0] ne "UPD");
  283. my $fName = $r[3];
  284. if($fName =~ m+\.\.+) {
  285. uLog 1, "Suspicious line $r, aborting";
  286. return 1;
  287. }
  288. if($isSingle) {
  289. next if($fName !~ m/$arg/);
  290. } else {
  291. my $isExcl;
  292. foreach my $ex (@excl) {
  293. $isExcl = 1 if($fName =~ m/$ex/ || "$src:$fName" =~ m/$ex/);
  294. }
  295. my $fPath = "$root/$fName";
  296. $fPath = $0 if($fPath =~ m/$mainPgm/);
  297. my $fileOk = ($lh{$fName} &&
  298. $lh{$fName}{TS} eq $r[1] &&
  299. $lh{$fName}{LEN} eq $r[2]);
  300. if($isExcl && !$fileOk) {
  301. uLog 1, "update: skipping $fName, matches exclude_from_update";
  302. $nSkipped++;
  303. next;
  304. }
  305. if($noSzCheck) {
  306. next if($isExcl || $fileOk);
  307. } else {
  308. my $sz = -s $fPath;
  309. next if($isExcl || ($fileOk && defined($sz) && $sz eq $r[2]));
  310. }
  311. }
  312. $upd_needJoin = 1 if($fName =~ m/commandref_frame/ || $fName=~ m/\d+.*.pm/);
  313. next if($fName =~ m/commandref.*html/ && $fName !~ m/frame/ && $canJoin);
  314. uLog 1, "List of new / modified files since last update:"
  315. if($isCheck && $nChanged == 0);
  316. $nChanged++;
  317. my $sfx = ($arg eq "checktime" ? " $r[1]" : "");
  318. $sfx =~ s/_.*//;
  319. uLog 1, "$r[0] $fName$sfx";
  320. next if($isCheck);
  321. my $remFile = upd_getUrl("$basePath/$fName");
  322. return if(!$remFile); # Error already reported
  323. if(length($remFile) ne $r[2]) {
  324. uLog 1, "Got ".length($remFile)." bytes for $fName, expected $r[2]";
  325. if($attr{global}{verbose} == 5) {
  326. upd_writeFile($root, $restoreDir, "$fName.corrupt", $remFile);
  327. uLog 1, "saving it to $fName.corrupt .";
  328. next;
  329. } else {
  330. uLog 1, "aborting.";
  331. return;
  332. }
  333. }
  334. return if(!upd_writeFile($root, $restoreDir, $fName, $remFile));
  335. }
  336. if($nChanged) {
  337. for my $f ($attr{global}{configfile}, $attr{global}{statefile}) {
  338. upd_saveConfig($root, $restoreDir, $f) if($f && $f !~ m,(^/|\.\.),);
  339. }
  340. }
  341. uLog 1, "nothing to do..." if($nChanged == 0 && $nSkipped == 0);
  342. if(@rl && ($nChanged || $nSkipped)) {
  343. uLog(1, "");
  344. uLog 1, "New entries in the CHANGED file:";
  345. map { uLog 1, $_ } @rl;
  346. }
  347. return if($isCheck);
  348. if(($arg eq "all" || $arg eq "force") && ($nChanged || $nSkipped)) {
  349. return if(!upd_writeFile($root, $restoreDir,
  350. "FHEM/$ctrlFileName", $remCtrlFile));
  351. }
  352. if($canJoin && $upd_needJoin && $curr == $max) {
  353. chdir($root);
  354. $cj .= " -noWarnings" if($cmod eq "full");
  355. uLog(1, "Calling $^X $cj, this may take a while");
  356. my $ret = `$^X $cj`;
  357. foreach my $l (split(/[\r\n]+/, $ret)) {
  358. uLog(1, $l);
  359. }
  360. }
  361. $upd_nChanged += $nChanged;
  362. return "" if(!$upd_nChanged);
  363. uLog(1, "");
  364. if($curr == $max) {
  365. uLog 1,
  366. 'update finished, "shutdown restart" is needed to activate the changes.';
  367. my $ss = AttrVal("global","sendStatistics",undef);
  368. if(!defined($ss)) {
  369. uLog(1, "");
  370. uLog(1, "Please consider using the global attribute sendStatistics");
  371. } elsif(defined($ss) && lc($ss) eq "onupdate") {
  372. uLog(1, "");
  373. my $ret = AnalyzeCommandChain(undef, "fheminfo send");
  374. $ret =~ s/.*server response:/server response:/ms;
  375. uLog(1, "fheminfo $ret");
  376. }
  377. }
  378. }
  379. sub
  380. upd_mv($$)
  381. {
  382. my ($src, $dest) = @_;
  383. if($src =~ m/\*/) {
  384. $src =~ m,^(.*)/([^/]+)$,;
  385. my ($dir, $pat) = ($1, $2);
  386. $pat = "^$pat\$";
  387. opendir(my $dh, $dir) || return "$dir: $!";
  388. while(my $r = readdir($dh)) {
  389. next if($r !~ m/$pat/ || "$dir/$r" eq $dest);
  390. my $mvret = mv("$dir/$r", $dest);
  391. return "MV $dir/$r $dest: $!" if(!$mvret);
  392. Log 3, "MV $dir/$r $dest";
  393. }
  394. closedir($dh);
  395. } else {
  396. return "MV $src $dest: $!" if(mv($src, $dest));
  397. }
  398. return undef;
  399. }
  400. sub
  401. upd_getChanges($$)
  402. {
  403. my ($root, $basePath) = @_;
  404. my $lFile = "";
  405. if(open(FH, "$root/CHANGED")) {
  406. foreach my $l (<FH>) { # first non-comment line
  407. next if($l =~ m/^#/);
  408. chomp $l;
  409. $lFile = $l;
  410. last;
  411. }
  412. close(FH);
  413. }
  414. my @lines = split(/[\r\n]/,upd_getUrl("$basePath/CHANGED"));
  415. my $maxLines = 25;
  416. my @ret;
  417. foreach my $line (@lines) {
  418. next if($line =~ m/^#/);
  419. last if($line eq "" || $line eq $lFile);
  420. push @ret, $line;
  421. if($maxLines-- < 1) {
  422. push @ret, "... rest of lines skipped.";
  423. last;
  424. }
  425. }
  426. return @ret;
  427. }
  428. sub
  429. upd_getUrl($)
  430. {
  431. my ($url) = @_;
  432. $url =~ s/%/%25/g;
  433. $upd_connecthash{url} = $url;
  434. $upd_connecthash{keepalive} = ($url =~ m/localUpdate/ ? 0 : 1); # Forum #49798
  435. my ($err, $data) = HttpUtils_BlockingGet(\%upd_connecthash);
  436. if($err) {
  437. uLog 1, $err;
  438. return "";
  439. }
  440. if(!$data) {
  441. uLog 1, "$url: empty file received";
  442. return "";
  443. }
  444. return $data;
  445. }
  446. sub
  447. upd_saveConfig($$$)
  448. {
  449. my($root, $restoreDir, $fName) = @_;
  450. return if(!$fName || !$restoreDir || configDBUsed() || !-r "$root/$fName");
  451. restoreDir_mkDir($root, "$restoreDir/$fName", 1);
  452. Log 1, "saving $fName";
  453. if(!copy("$root/$fName", "$root/$restoreDir/$fName")) {
  454. uLog 1, "copy $root/$fName $root/$restoreDir/$fName failed:$!, ".
  455. "aborting the update";
  456. return 0;
  457. }
  458. }
  459. sub
  460. upd_writeFile($$$$)
  461. {
  462. my($root, $restoreDir, $fName, $content) = @_;
  463. # copy the old file and save the new
  464. restoreDir_mkDir($root, $fName, 1);
  465. restoreDir_mkDir($root, "$restoreDir/$fName", 1) if($restoreDir);
  466. if($restoreDir && -f "$root/$fName" &&
  467. ! copy("$root/$fName", "$root/$restoreDir/$fName")) {
  468. uLog 1, "copy $root/$fName $root/$restoreDir/$fName failed:$!, ".
  469. "aborting the update";
  470. return 0;
  471. }
  472. my $rest = ($restoreDir ? "trying to restore the previous version and ":"").
  473. "aborting the update";
  474. my $fPath = "$root/$fName";
  475. $fPath = $0 if($fPath =~ m/$mainPgm/);
  476. if(!open(FD, ">$fPath")) {
  477. uLog 1, "open $fPath failed: $!, $rest";
  478. copy "$root/$restoreDir/$fName", "$root/$fName" if($restoreDir);
  479. return 0;
  480. }
  481. binmode(FD);
  482. print FD $content;
  483. close(FD);
  484. my $written = -s "$fPath";
  485. if($written != length($content)) {
  486. uLog 1, "writing $fPath failed: $!, $rest";
  487. copy "$root/$restoreDir/$fName", "$fPath" if($restoreDir);
  488. return;
  489. }
  490. cfgDB_FileUpdate("$fPath") if(configDBUsed());
  491. return 1;
  492. }
  493. 1;
  494. =pod
  495. =item command
  496. =item summary update FHEM program files from the central repository
  497. =item summary_DE FHEM Programmdateien aktualisieren
  498. =begin html
  499. <a name="update"></a>
  500. <h3>update</h3>
  501. <ul>
  502. <code>update [&lt;fileName&gt;|all|check|checktime|force]
  503. [http://.../controlfile]</code>
  504. <br>or<br>
  505. <code>update [add source|delete source|list|reset]</code>
  506. <br>
  507. <br>
  508. Update the FHEM installation. Technically this means update will download
  509. the controlfile(s) first, compare it to the local version of the file in the
  510. moddir/FHEM directory, and download each file where the attributes (timestamp
  511. and filelength) are different. Upon completion it triggers the global:UPDATE
  512. event.
  513. <br>
  514. With the commands add/delete/list/reset you can manage the list of
  515. controlfiles, e.g. for thirdparty packages.
  516. Notes:
  517. <ul>
  518. <li>The contrib directory will not be updated.</li>
  519. <li>The files are automatically transferred from the source repository
  520. (SVN) to the web site once a day, at 7:45 CET / CEST.</li>
  521. <li>The all argument is default.</li>
  522. <li>The force argument will disregard the local file.</li>
  523. <li>The check argument will only display the files it would download, and
  524. the last section of the CHANGED file.</li>
  525. <li>checktime is like check, but additionally displays the update
  526. timestamp of the new file, which is usually the version date +1 day.
  527. </li>
  528. <li>Specifying a filename will only download matching files (regexp).</li>
  529. </ul>
  530. See also the restore command.<br>
  531. <br>
  532. Examples:<br>
  533. <ul>
  534. <li>update check</li>
  535. <li>update</li>
  536. <li>update force</li>
  537. <li>update check http://fhem.de/fhemupdate/controls_fhem.txt</li>
  538. </ul>
  539. <a name="updateattr"></a>
  540. <br>
  541. <b>Attributes</b> (use attr global ...)
  542. <ul>
  543. <a name="updateInBackground"></a>
  544. <li>updateInBackground<br>
  545. If this attribute is set (to 1), the update will be executed in a
  546. background process. The return message is communicated via events, and
  547. in telnet the inform command is activated, in FHEMWEB the Event
  548. Monitor. Default is set. Set it to 0 to switch it off.
  549. </li><br>
  550. <a name="updateNoFileCheck"></a>
  551. <li>updateNoFileCheck<br>
  552. If set, the command won't compare the local file size with the expected
  553. size. This attribute was introduced to satisfy some experienced FHEM
  554. user, its default value is 0.
  555. </li><br>
  556. <a name="backup_before_update"></a>
  557. <li>backup_before_update<br>
  558. If this attribute is set, an update will back up your complete
  559. installation via the <a href="#backup">backup</a> command. The default
  560. is not set as update relies on the restore feature (see below).<br>
  561. Example:<br>
  562. <ul>
  563. attr global backup_before_update
  564. </ul>
  565. </li><br>
  566. <a name="exclude_from_update"></a>
  567. <li>exclude_from_update<br>
  568. Contains a space separated list of fileNames (regexps) which will be
  569. excluded by an update. The special value commandref will disable calling
  570. commandref_join at the end, i.e commandref.html will be out of date.
  571. The module-only documentation is not affected and is up-to-date.<br>
  572. Example:<br>
  573. <ul>
  574. attr global exclude_from_update 21_OWTEMP.pm FS20.off.png
  575. </ul>
  576. The regexp is checked against the filename and the source:filename
  577. combination. To exclude the updates for FILE.pm from fhem.de, as you are
  578. updating it from another source, specify fhem.de.*:FILE.pm
  579. </li><br>
  580. <li><a href="#restoreDirs">restoreDirs</a></li><br>
  581. </ul>
  582. </ul>
  583. =end html
  584. =begin html_DE
  585. <a name="update"></a>
  586. <h3>update</h3>
  587. <ul>
  588. <code>update [&lt;fileName&gt;|all|check|checktime|force]
  589. [http://.../controlfile]</code>
  590. <br>oder<br>
  591. <code>update [add source|delete source|list|reset]</code>
  592. <br>
  593. <br>
  594. Erneuert die FHEM Installation. D.h. es wird (werden) zuerst die
  595. Kontroll-Datei(en) heruntergeladen, und mit der lokalen Version dieser Datei
  596. in moddir/FHEM verglichen. Danach werden alle in der Kontroll-Datei
  597. spezifizierten Dateien heruntergeladen, deren Gr&ouml;&szlig;e oder
  598. Zeitstempel sich unterscheidet. Wenn dieser Ablauf abgeschlossen ist, wird
  599. das globale UPDATE Ereignis ausgel&ouml;st.
  600. <br>
  601. Mit den Befehlen add/delete/list/reset kann man die Liste der Kontrolldateien
  602. pflegen.
  603. <br>
  604. <br>
  605. Zu beachten:
  606. <ul>
  607. <li>Das contrib Verzeichnis wird nicht heruntergeladen.</li>
  608. <li>Die Dateien werden auf der Webseite einmal am Tag um 07:45 MET/MEST aus
  609. der Quell-Verwaltungssystem (SVN) bereitgestellt.</li>
  610. <li>Das all Argument ist die Voreinstellung.</li>
  611. <li>Das force Argument beachtet die lokale controls_fhem.txt Datei
  612. nicht.</li>
  613. <li>Das check Argument zeigt die neueren Dateien an, und den letzten
  614. Abschnitt aus der CHANGED Datei</li>
  615. <li>checktime zeigt zus&auml;tzlich zu check den update-Zeitstempel der
  616. neuen Datei, &uuml;blicherweise version Zeitstempel +1 Tag.
  617. </li>
  618. <li>Falls man &lt;fileName&gt; spezifiziert, dann werden nur die Dateien
  619. heruntergeladen, die diesem Regexp entsprechen.</li>
  620. </ul>
  621. Siehe also das restore Befehl.<br>
  622. <br>
  623. Beispiele:<br>
  624. <ul>
  625. <li>update check</li>
  626. <li>update</li>
  627. <li>update force</li>
  628. <li>update check http://fhem.de/fhemupdate/controls_fhem.txt</li>
  629. </ul>
  630. <a name="updateattr"></a>
  631. <br>
  632. <b>Attribute</b> (sind mit attr global zu setzen)
  633. <ul>
  634. <a name="updateInBackground"></a>
  635. <li>updateInBackground<br>
  636. Wenn dieses Attribut gesetzt ist, wird das update Befehl in einem
  637. separaten Prozess ausgef&uuml;hrt, und alle Meldungen werden per Event
  638. &uuml;bermittelt. In der telnet Sitzung wird inform, in FHEMWEB wird
  639. das Event Monitor aktiviert. Die Voreinstellung ist an, zum
  640. Deaktivieren bitte Attribut auf 0 setzen.
  641. </li><br>
  642. <a name="updateNoFileCheck"></a>
  643. <li>updateNoFileCheck<br>
  644. Wenn dieses Attribut gesetzt ist, wird die Gr&ouml;&szlig;e der bereits
  645. vorhandenen, lokalen Datei nicht mit der Sollgr&ouml;&szlig;e
  646. verglichen. Dieses Attribut wurde nach nicht genau spezifizierten Wnsch
  647. erfahrener FHEM Benutzer eingefuehrt, die Voreinstellung ist 0.
  648. </li><br>
  649. <a name="backup_before_update"></a>
  650. <li>backup_before_update<br>
  651. Wenn dieses Attribut gesetzt ist, erstellt FHEM eine Sicherheitskopie
  652. der FHEM Installation vor dem update mit dem backup Befehl. Die
  653. Voreinstellung is "nicht gesetzt", da update sich auf das restore
  654. Feature verl&auml;sst, s.u.<br>
  655. Beispiel:<br>
  656. <ul>
  657. attr global backup_before_update
  658. </ul>
  659. </li><br>
  660. <a name="exclude_from_update"></a>
  661. <li>exclude_from_update<br>
  662. Enth&auml;lt eine Liste durch Leerzeichen getrennter Dateinamen
  663. (regexp), welche nicht im update ber&uuml;cksichtigt werden.<br>
  664. Falls der Wert commandref enth&auml;lt, dann wird commandref_join.pl
  665. nach dem update nicht aufgerufen, d.h. die Gesamtdokumentation ist
  666. nicht mehr aktuell. Die Moduldokumentation bleibt weiterhin aktuell.
  667. <br>
  668. Beispiel:<br>
  669. <ul>
  670. attr global exclude_from_update 21_OWTEMP.pm temp4hum4.gplot
  671. </ul>
  672. Der Regexp wird gegen den Dateinamen und gegen Quelle:Dateiname
  673. gepr&uuml;ft. Um die Datei FILE.pm von updates von fhem.de
  674. auszuschlie&szlig;en, weil sie von einer anderen Quelle bezogen wird,
  675. kann man fhem.de.*:FILE.pm spezifizieren.
  676. </li><br>
  677. <li><a href="#restoreDirs">restoreDirs</a></li><br>
  678. </ul>
  679. </ul>
  680. =end html_DE
  681. =cut