mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
fhem.pl: add optional shutdown exit value (Forum #45202)
git-svn-id: https://svn.fhem.de/fhem/trunk@10220 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f3956d61b1
commit
68fc2cd687
@ -1233,16 +1233,18 @@ The following local attributes are used by a wider range of devices:
|
||||
<a name="shutdown"></a>
|
||||
<h3>shutdown</h3>
|
||||
<ul>
|
||||
<code>shutdown [restart]</code>
|
||||
<code>shutdown [restart|exitValue]</code>
|
||||
<br><br>
|
||||
Shut down the server (after saving the <a href="#statefile">state information
|
||||
</a>). It triggers the global:SHUTDOWN event. If the optional restart
|
||||
parameter is specified, fhem tries to restart itself.
|
||||
parameter is specified, fhem tries to restart itself. exitValue may be
|
||||
important for start scripts.
|
||||
<br><br>
|
||||
Example:
|
||||
<ul>
|
||||
<code>shutdown</code><br>
|
||||
<code>shutdown restart</code>
|
||||
<code>shutdown restart</code><br>
|
||||
<code>shutdown 1</code><br>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
@ -1309,16 +1309,18 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
<a name="shutdown"></a>
|
||||
<h3>shutdown</h3>
|
||||
<ul>
|
||||
<code>shutdown [restart]</code>
|
||||
<code>shutdown [restart|exitValue]</code>
|
||||
<br><br>
|
||||
Der Befehl fährt den Server herunter (nach dem sichern aller <a
|
||||
href="#statefile">Gerätestati</a>). Er triggert das global:SHUTDOWN
|
||||
Ereignis. Mit der optionalen Parameter restart startet FHEM danach neu.
|
||||
exitValue ist bei bestimmten Start-programmen von n&oulm;ten.
|
||||
<br><br>
|
||||
Beispiel:
|
||||
<ul>
|
||||
<code>shutdown</code><br>
|
||||
<code>shutdown restart</code>
|
||||
<code>shutdown restart</code><br>
|
||||
<code>shutdown 1</code>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
11
fhem/fhem.pl
11
fhem/fhem.pl
@ -364,7 +364,7 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
||||
"setdefaultattr" => { Fn=>"CommandDefaultAttr",
|
||||
Hlp=>"<attrname> <attrvalue>,set attr for following definitions" },
|
||||
"shutdown"=> { Fn=>"CommandShutdown",
|
||||
Hlp=>"[restart],terminate the server" },
|
||||
Hlp=>"[restart|exitValue],terminate the server" },
|
||||
"sleep" => { Fn=>"CommandSleep",
|
||||
Hlp=>"<sec> [<id>] [quiet],sleep for sec, 3 decimal places" },
|
||||
"trigger" => { Fn=>"CommandTrigger",
|
||||
@ -1496,7 +1496,12 @@ sub
|
||||
CommandShutdown($$)
|
||||
{
|
||||
my ($cl, $param) = @_;
|
||||
return "Usage: shutdown [restart]"
|
||||
my $exitValue = 0;
|
||||
if($param && $param =~ m/^(\d+)$/) {
|
||||
$exitValue = $1;
|
||||
$param = "";
|
||||
}
|
||||
return "Usage: shutdown [restart|exitvalue]"
|
||||
if($param && $param ne "restart");
|
||||
|
||||
DoTrigger("global", "SHUTDOWN", 1);
|
||||
@ -1517,7 +1522,7 @@ CommandShutdown($$)
|
||||
exec('cmd.exe /C net stop fhem & net start fhem');
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
exit($exitValue);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user