diff --git a/emhttp/languages/en_US/helptext.txt b/emhttp/languages/en_US/helptext.txt index 7da272e46..30712c121 100644 --- a/emhttp/languages/en_US/helptext.txt +++ b/emhttp/languages/en_US/helptext.txt @@ -2492,6 +2492,10 @@ If set to yes when wake on lan packets are received checks are carrried out for If set to yes when wake on lan packets are received checks are carrried out for LXC otherwise LXC will be ignored. The LXC plugin needs to be installed for LXC to be processed. :end +:WOL_run_shutdown_help: +If set to yes when wake on lan packets are received checks are carrried out and if enabled for service and that service is running the entity will be shutdown. System has to be set to Enabled and Shutdwon for it to be action. +:end + :WOL_interface_help: Specify the interface to the daemon to bind to. Some interfaces may not be able to recieve etherframe packets. Recommend to bind to a physical interface. :end diff --git a/emhttp/plugins/dynamix/WOL.page b/emhttp/plugins/dynamix/WOL.page index b80b33968..cfda05d98 100644 --- a/emhttp/plugins/dynamix/WOL.page +++ b/emhttp/plugins/dynamix/WOL.page @@ -27,7 +27,7 @@ if (count($_POST)) { foreach($update_file as $type => $types) { foreach($types as $name => $details) { if ($details['user_mac'] == "") $details['user_mac'] = "None Defined"; - if ($details['user_mac'] == "None Defined" && $details['enable'] == "enable") unset($update_file[$type][$name]) ; + if ($details['user_mac'] == "None Defined" && ($details['enable'] == "enable" || $details['enable'] == "shutdown")) unset($update_file[$type][$name]) ; } } } diff --git a/emhttp/plugins/dynamix/WOLSettings.page b/emhttp/plugins/dynamix/WOLSettings.page index 4b68c8d40..7607edb76 100644 --- a/emhttp/plugins/dynamix/WOLSettings.page +++ b/emhttp/plugins/dynamix/WOLSettings.page @@ -65,6 +65,14 @@ _(Enable VM actions)_: :WOL_run_VM_help: +_(Enable Shutdown actions)_: +: + +:WOL_run_shutdown_help: + _(Interface to listern on)_: : "; $html .= mk_option($macaddr["enable"] , "disable", _("Disabled")); $html .= mk_option($macaddr["enable"] , "enable", _("Enabled")); + $html .= mk_option($macaddr["enable"] , "shutdown", _("Enabled and Shutdown")); $html .= "".$user_mac_str.""; $text = ""; } diff --git a/emhttp/plugins/dynamix/include/WOLrun.php b/emhttp/plugins/dynamix/include/WOLrun.php index 7ea439a9e..ed9c5ebc4 100755 --- a/emhttp/plugins/dynamix/include/WOLrun.php +++ b/emhttp/plugins/dynamix/include/WOLrun.php @@ -28,6 +28,7 @@ extract(parse_ini_file("/boot/config/wol.cfg")) ; if (!isset($RUNLXC)) $RUNLXC = "y"; if (!isset($RUNVM)) $RUNVM = "y"; if (!isset($RUNDocker)) $RUNDocker = "y"; +if (!isset($RUNSHUT)) $RUNSHUT = "n"; $arrEntries = [] ; if ($libvirtd_running && $RUNVM == "y") { @@ -116,8 +117,8 @@ foreach($arrEntries as $type => $detail) $found = array_key_exists($mac,$mac_list); -if ($found && $mac_list[$mac]['enable'] == "enable") { - echo _("Found "). $mac . " ".$mac_list[$mac]['type']." ".$mac_list[$mac]['name']; +if ($found && $mac_list[$mac]['enable'] != "disable") { + echo _("Found"). " " . $mac . " ".$mac_list[$mac]['type']." ".$mac_list[$mac]['name']; switch ($mac_list[$mac]['type']) { case "VM": @@ -127,6 +128,7 @@ if ($found && $mac_list[$mac]['enable'] == "enable") { $state = $lv->domain_state_translate($dom['state']); switch ($state) { case 'running': + if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "shutdown") $lv->domain_shutdown("{$mac_list[$mac]['name']}"); break; case 'paused': case 'pmsuspended': @@ -142,6 +144,7 @@ if ($found && $mac_list[$mac]['enable'] == "enable") { $state = getContainerStats($mac_list[$mac]['name'], "State"); switch ($state) { case 'RUNNING': + if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "shutdown") shell_exec("lxc-stop {$mac_list[$mac]['name']}"); break; case 'FROZEN': shell_exec("lxc-unfreeze {$mac_list[$mac]['name']}"); @@ -155,7 +158,9 @@ if ($found && $mac_list[$mac]['enable'] == "enable") { if ($dockerd_running && $RUNDOCKER == "y") { switch ($mac_list[$mac]['state']) { - + case "running": + if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "shutdown") shell_exec("docker stop {$mac_list[$mac]['name']}"); + break; case "exited": case "created": shell_exec("docker start {$mac_list[$mac]['name']}");