From ff71faa937ccd5bd561bd5398993a48b030b27b1 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Mon, 21 Dec 2015 12:43:26 +0000 Subject: [PATCH] fhem.pl: add optional shutdown exit value (Forum #45202) git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@10220 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/docs/commandref_frame.html | 8 +++++--- fhem/docs/commandref_frame_DE.html | 6 ++++-- fhem/fhem.pl | 11 ++++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index 30d008572..758a99a31 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -1233,16 +1233,18 @@ The following local attributes are used by a wider range of devices:

shutdown

diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index 73f026e59..fd2748e2b 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -1309,16 +1309,18 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:

shutdown

diff --git a/fhem/fhem.pl b/fhem/fhem.pl index c78d7184c..01c0e2776 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -364,7 +364,7 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ". "setdefaultattr" => { Fn=>"CommandDefaultAttr", Hlp=>" ,set attr for following definitions" }, "shutdown"=> { Fn=>"CommandShutdown", - Hlp=>"[restart],terminate the server" }, + Hlp=>"[restart|exitValue],terminate the server" }, "sleep" => { Fn=>"CommandSleep", Hlp=>" [] [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); }