diff --git a/emhttp/plugins/dynamix/WOL.page b/emhttp/plugins/dynamix/WOL.page deleted file mode 100644 index ad8141f80..000000000 --- a/emhttp/plugins/dynamix/WOL.page +++ /dev/null @@ -1,116 +0,0 @@ -Menu="UNRAID-OS" -Title="WOL for Services" -Icon="fa-bell" -Tag="server" ---- -$data) { - if ($postkey=="#apply") continue; - $keys = explode(";",$postkey); - if (count($keys) >1) $update_file[$keys[1]][$keys[2]][$keys[0]]=$data; - } - - 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" || $details['enable'] == "shutdown" || $details['enable'] == "suspend")) unset($update_file[$type][$name]) ; - } - } - } - unset($_POST) ; - file_put_contents("/boot/config/wol.json",json_encode($update_file)); - echo ''; -} -?> - - - - -:WOL_intro_help: - -
-
- -

- - - - diff --git a/emhttp/plugins/dynamix/WOLSettings.page b/emhttp/plugins/dynamix/WOLSettings.page deleted file mode 100644 index 12d665008..000000000 --- a/emhttp/plugins/dynamix/WOLSettings.page +++ /dev/null @@ -1,125 +0,0 @@ -Menu="OtherSettings" -Type="xmenu" -Title="WOL for Services Settings" -Icon="fa-bell" -Tag="share-alt" ---- - - "no", - "RUNDOCKER" => "y", - "RUNLXC" => "y", - "RUNVM" => "y", - "RUNSHUT" => "n", - "INTERFACE" => "eth0", - "IFMODE" => "n", - "LOGFILE" => "syslog" -]; -if (!isset($current['LOGFILE'])) $current['LOGFILE'] = "syslog"; - -function locked($source,$port) { - global $members; - foreach ($members as $member => $value) { - if ($member == $source) continue; - if ($value['BONDING']=='yes' && in_array($port,explode(',',$value['BONDNICS']))) return $value['BONDNAME'].' '.$member; - if ($value['BRIDGING']=='yes' && in_array($port,explode(',',$value['BRNICS']))) return $value['BRNAME'].' '.$member; - } - return false; -} - -?> - -
- - - - -_(Enable WOL for services)_: -: - -:WOL_enable_help: - -_(Enable Docker actions)_: - -: - -:WOL_run_docker_help: - -_(Enable LXC actions)_: -: - -:WOL_run_LXC_help: - -_(Enable VM actions)_: -: - -:WOL_run_VM_help: - -_(Enable Shutdown / Suspend actions)_: -: - -:WOL_run_shutdown_help: - -_(Interface to listen on)_: -: - -:WOL_interface_help: - -_(Interface promiscuous mode)_: -: - -:WOL_promiscuous_mode_help: - -_(Log file)_: -: > - - -:WOL_log_file_help: - -  -: -
diff --git a/emhttp/plugins/dynamix/event/array_started/WOLStart b/emhttp/plugins/dynamix/event/array_started/WOLStart deleted file mode 100755 index 0c1f4626c..000000000 --- a/emhttp/plugins/dynamix/event/array_started/WOLStart +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -/usr/local/emhttp/plugins/dynamix/scripts/WOL_action load & diff --git a/emhttp/plugins/dynamix/event/stopping/WOLStop b/emhttp/plugins/dynamix/event/stopping/WOLStop deleted file mode 100755 index 70321d7b1..000000000 --- a/emhttp/plugins/dynamix/event/stopping/WOLStop +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -/usr/local/emhttp/plugins/dynamix/include/script/WOL_action stop & diff --git a/emhttp/plugins/dynamix/include/WOL.php b/emhttp/plugins/dynamix/include/WOL.php deleted file mode 100644 index da0b7b8ce..000000000 --- a/emhttp/plugins/dynamix/include/WOL.php +++ /dev/null @@ -1,134 +0,0 @@ - -get_domains() ?:[]; - sort($vms,SORT_NATURAL); - foreach($vms as $vm){ - $arrEntries['VM'][$vm]['interfaces'] = $lv->get_nic_info($vm); - $arrEntries['VM'][$vm]['name'] = $vm; - } -} -if ($dockerd_running) { - $DockerClient = new DockerClient(); - $containers = $DockerClient->getDockerJSON("/containers/json?all=1"); - foreach($containers as $ct) - $arrEntries['Docker'][substr($ct["Names"][0],1)] = [ - 'interfaces' => ['0 '=> ['mac' => isset($ct["NetworkSettings"]["Networks"]["bridge"]["MacAddress"]) ? $ct["NetworkSettings"]["Networks"]["bridge"]["MacAddress"] : ""]], - 'name' => substr($ct["Names"][0],1), - ]; -} -if ($lxc_ls_exist) { - $lxc = explode("\n",shell_exec("lxc-ls -1")) ; - $lxcpath = trim(shell_exec("lxc-config lxc.lxcpath")); - foreach ($lxc as $lxcname) { - if ($lxcname == "") continue; - $value = explode("=",shell_exec("cat $lxcpath/$lxcname/config | grep 'hwaddr'")); - $arrEntries['LXC'][$lxcname]['interfaces'][0]['mac'] = trim($value[1]); - $arrEntries['LXC'][$lxcname]['name'] = $lxcname; - } -} - -if (is_file("/boot/config/wol.json")) $user_mac = json_decode(file_get_contents("/boot/config/wol.json"),true); else $user_mac = []; - -foreach($arrEntries as $key => $data) { - $type=$key; - foreach($data as $data2){ - $name=$data2['name']; - if (isset($user_mac[$type][$name])) { - $name=$name; - $arrEntries[$type][$name]['enable'] = $user_mac[$type][$name]['enable']; - $arrEntries[$type][$name]['user_mac'] = strtolower($user_mac[$type][$name]['user_mac']); - } else { - $arrEntries[$type][$name]['enable'] = 'enable'; - $arrEntries[$type][$name]['user_mac'] = 'None Defined'; - } - } -} - -switch ($_POST['table']) { - -case 't1load': - $arrMacs = $arrEntries; - $html = ""._('Service').""._('Name').""._('Mac Address').""._('Enabled').""._('User Mac Address').""; - $html .= ""; - ksort($arrMacs); - foreach($arrMacs as $systype => $m) { - foreach($m as $macaddr) { - if ($systype == "") continue; - - $html .= ""; - $macs = ""; - foreach($macaddr['interfaces'] as $intdetail) - { - $macs .= " {$intdetail['mac']}" ; - } - $html .= "$systype"; - $selecttypename="enable;".$systype.";".$macaddr['name']; - $mactypename=htmlspecialchars("user_mac;".$systype.";".$macaddr['name']); - $mactypeid=htmlspecialchars("user_mac".$systype."".$macaddr['name']); - $user_mac_str = ''; - $html .= "{$macaddr['name']}$macs"; - $html .="".$user_mac_str.""; - $text = ""; - } -} - if (count($arrMacs) < 1) { - $html .= ""; - $html .= ""._("No Entries").""; - } - $html .= ""; - - $rtn = array(); - $rtn['html'] = $html; - echo json_encode($rtn); - break; - -case "macaddress": - $seed = 1; - $prefix = '62:00:00'; - $prefix .=':'.macbyte(($seed * rand()) % 256).':'.macbyte(($seed * rand()) % 256).':'.macbyte(($seed * rand()) % 256); - echo json_encode(['mac' => $prefix]); - break; - -} -?> diff --git a/emhttp/plugins/dynamix/include/WOLrun.php b/emhttp/plugins/dynamix/include/WOLrun.php deleted file mode 100755 index 8cbb4ab69..000000000 --- a/emhttp/plugins/dynamix/include/WOLrun.php +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/php - $string) { - if (strpos($string, $option) !== FALSE) - return trim(explode(':', $string)[1]); - } -} - -$mac = strtolower($argv[1]); - -$libvirtd_running = is_file('/var/run/libvirt/libvirtd.pid') ; -$dockerd_running = is_file('/var/run/dockerd.pid'); -$lxc_ls_exist = is_file('/usr/bin/lxc-ls'); -#$RUNDOCKER = $RUNLXC = $RUNVM = true; -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") { - $vms = $lv->get_domains(); - sort($vms,SORT_NATURAL); - foreach($vms as $vm){ - $arrEntries['VM'][$vm]['interfaces'] = $lv->get_nic_info($vm); - $arrEntries['VM'][$vm]['name'] = $vm; - } -} -if ($dockerd_running && $RUNDOCKER == "y") { - $DockerClient = new DockerClient(); - $containers = $DockerClient->getDockerJSON("/containers/json?all=1"); - foreach($containers as $container) - $arrEntries['Docker'][ substr($container["Names"][0],1) ] = [ - 'interfaces' => ['0' => ['mac' => isset($container["NetworkSettings"]["Networks"]["bridge"]["MacAddress"]) ? $container["NetworkSettings"]["Networks"]["bridge"]["MacAddress"]:""]], - 'name' => substr($container["Names"][0],1), - 'state' => $container["State"], - ]; -} - -if ($lxc_ls_exist && $RUNLXC == "y") { - $lxc = explode("\n",shell_exec("lxc-ls -1")) ; - $lxcpath = trim(shell_exec("lxc-config lxc.lxcpath")); - foreach ($lxc as $lxcname) { - if ($lxcname == "") continue; - $values = explode("=",shell_exec("cat $lxcpath/$lxcname/config | grep 'hwaddr'")); - $arrEntries['LXC'][$lxcname]['interfaces'][0]['mac'] = trim($values[1]); - $arrEntries['LXC'][$lxcname]['name'] = $lxcname; - } -} - -if (is_file("/boot/config/wol.json")) $user_mac = json_decode(file_get_contents("/boot/config/wol.json"),true); else $user_mac = []; - -foreach($arrEntries as $typekey => $typedata) -{ - foreach($typedata as $typeEntry){ - $name=$typeEntry['name']; - if (isset($user_mac[$typekey][$name])) { - - $name=$name; - - $arrEntries[$typekey][$name]['enable'] = $user_mac[$typekey][$name]['enable']; - $arrEntries[$typekey][$name]['user_mac'] = strtolower($user_mac[$typekey][$name]['user_mac']); - - } else { - $arrEntries[$typekey][$name]['enable'] = "enable"; - $arrEntries[$typekey][$name]['user_mac'] = 'None Defined'; - } - } -} - - -$mac_list=[]; -foreach($arrEntries as $type => $detail) - { - foreach($detail as $name => $entryDetail) - { - foreach($entryDetail['interfaces'] as $interfaces) - { - $interfaces['mac'] = strtolower($interfaces['mac']); - if($interfaces['mac'] == "" && $entryDetail['user_mac'] == "None Defined") continue; - if (isset($entryDetail['state'])) $state = $entryDetail['state']; else $state = ""; - if (isset($entryDetail['enable']) && !$entryDetail['enable'] ) $enable = false; else $enable = true; - if ($entryDetail['user_mac'] != "None Defined") { - $mac_list[$entryDetail['user_mac']] = [ - 'type' => $type, - 'name' => $name, - 'state' => $state, - 'enable' => $entryDetail['enable'], - ]; - } - if ($interfaces['mac'] != "") { - $mac_list[$interfaces['mac']] = [ - 'type' => $type, - 'name' => $name, - 'state' => $state, - 'enable' => $entryDetail['enable'], - ]; - } - } - } - } - - - - $found = array_key_exists($mac,$mac_list); - - -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": - if ($libvirtd_running && $RUNVM == "y") { - $res = $lv->get_domain_by_name($mac_list[$mac]['name']); - $dom = $lv->domain_get_info($res); - $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']}"); - if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "suspend") $lv->domain_suspend("{$mac_list[$mac]['name']}"); - break; - case 'paused': - case 'pmsuspended': - $lv->domain_resume("{$mac_list[$mac]['name']}"); - break; - default: - $lv->domain_start("{$mac_list[$mac]['name']}"); - } - } - break; - case "LXC": - if ($lxc_ls_exist && $RUNLXC == "y") { - $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']}"); - if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "suspend") shell_exec("lxc-freeze {$mac_list[$mac]['name']}"); - break; - case 'FROZEN': - shell_exec("lxc-unfreeze {$mac_list[$mac]['name']}"); - break; - default: - shell_exec("lxc-start {$mac_list[$mac]['name']}"); - } - } - break; - case "Docker": - 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']}"); - if ($RUNSHUT == "y" && $mac_list[$mac]['enable'] == "suspend") shell_exec("docker pause {$mac_list[$mac]['name']}"); - break; - case "exited": - case "created": - shell_exec("docker start {$mac_list[$mac]['name']}"); - break; - case "paused": - shell_exec("docker unpause {$mac_list[$mac]['name']}"); - } - } - break; - } - } else { - if ($mac_list[$mac]['enable'] == "disable") echo $mac . " " . _(" has not been actioned as set to disabled"); - else echo _("Not Found"). " " . $mac . " " . _("ignoring or Maybe actions disabled for type(Docker/VM/LXC)"); - } - -?> diff --git a/emhttp/plugins/dynamix/scripts/WOL_action b/emhttp/plugins/dynamix/scripts/WOL_action deleted file mode 100755 index 610cd5f91..000000000 --- a/emhttp/plugins/dynamix/scripts/WOL_action +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# -# script: WOL_action -# -# Startup script for unraidwold -# -# Simon Fairweather - Initial Script October 2023 - -DAEMON="unraidwold" -BINARY="/usr/local/bin/unraidwold" - -# run & log functions -. /etc/rc.d/rc.runlog -. /boot/config/wol.cfg - -unraidwold_running(){ - sleep 0.1 - ps axc | grep -q ' unraidwold' -} - -unraidwold_start(){ - log "Starting $DAEMON..." - local REPLY - if unraidwold_running; then - REPLY="Already started" - else - nohup $BINARY $1 $2 $3 $4 $5 $6 > /dev/null & - fi - log "$DAEMON... $REPLY." -} - -unraidwold_stop(){ - log "Stopping $DAEMON..." - local REPLY - if ! unraidwold_running; then - REPLY="Already stopped" - else - killall -TERM $DAEMON - if ! unraidwold_running; then REPLY="Stopped"; else REPLY="Failed"; fi - fi - log "$DAEMON... $REPLY." -} - -unraidwold_status(){ - if unraidwold_running; then - echo "$DAEMON is currently running." - else - echo "$DAEMON is not running." - exit 1 - fi -} - -unraidwold_load() -{ - if unraidwold_running; then - unraidwold_stop - fi - sleep 1 - if [ "$WOLENABLED" == "yes" ]; then - interfacemode="" - logoptions="" - - if [ "$IFMODE" == "y" ]; then - interfacemode="--promiscuous" - fi - - if [ "$LOGFILE" != "syslog" ]; then - logoptions="--log $LOGFILE" - fi - - unraidwold_start --interface $INTERFACE $interfacemode $logoptions - fi - - } - -case "$1" in -'start') - unraidwold_start $2 $3 $4 $5 $6 - ;; -'stop') - unraidwold_stop - ;; -'status') - unraidwold_status - ;; - 'load') - unraidwold_load - ;; -*) - echo "Usage: $BDAEMON start|stop|restart|status" - exit 1 -esac -exit 0 \ No newline at end of file diff --git a/emhttp/plugins/dynamix/sheets/WOL.css b/emhttp/plugins/dynamix/sheets/WOL.css deleted file mode 100644 index 6c8dbf120..000000000 --- a/emhttp/plugins/dynamix/sheets/WOL.css +++ /dev/null @@ -1,11 +0,0 @@ -table#t1{margin-top:0;font-family:clear-sans} -table#t1 thead tr th{font-weight:bold} -table#t1 tbody tr td{padding:4px 20px 4px 0;margin:0;text-align:left;white-space:normal} -table#t1 tbody tr td:nth-child(1){width:10%} -table#t1 tbody tr td:nth-child(2){width:30%} -table#t1 tbody tr td:nth-child(3){width:15%} -table#t1 tbody tr td:nth-child(4){width:20%} -table#t1 tbody tr td:nth-child(5){width:25%;padding-right:0} -table.t1.tablesorter .filtered{display:none} -.tablesorter-header-inner{font-family:clear-sans;font-weight:bold} -#macform .mac_generate{cursor:pointer;margin-left:-5px;color:#08C;font-size:1.3rem;transform:translate(0px, 2px)} \ No newline at end of file