diff options
author | stompro <gitemail@stompro.org> | 2009-09-11 11:02:50 -0500 |
---|---|---|
committer | stompro <gitemail@stompro.org> | 2009-09-11 11:02:50 -0500 |
commit | 1b197e555d5abc8d2505456cb2f0b347a4d4eaa2 (patch) | |
tree | 0c697123a3bdb57c3dd647a1dd444be2c8c57eea | |
parent | 8acfca38c7d05d10d49fba585bf9305952f31562 (diff) | |
download | pfsense-1b197e555d5abc8d2505456cb2f0b347a4d4eaa2.zip pfsense-1b197e555d5abc8d2505456cb2f0b347a4d4eaa2.tar.gz |
Added checks to wol command execution to make it more obvious when the script fails.
If the wol command returns with anything other than 0, alert the user that the command
failed, and that they should look at the system log to find out why the command failed.
I'm adding this out of frustration with the fact that the wol command hasn't been included
at all in recent snapshots, and because the webgui doesn't give any indication of the command
not working, it took much longer for me to figure out why it wasn't working. I hope
this can save someone else time.
-rwxr-xr-x | usr/local/www/services_wol.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/usr/local/www/services_wol.php b/usr/local/www/services_wol.php index 389047a..8fe4ad7 100755 --- a/usr/local/www/services_wol.php +++ b/usr/local/www/services_wol.php @@ -50,10 +50,16 @@ if($_GET['wakeall'] <> "") { foreach ($a_wol as $wolent) { $mac = $wolent['mac']; $if = $wolent['interface']; + $description = $wolent['descr']; $bcip = gen_subnet_max(get_interface_ip($if), get_interface_subnet($if)); - mwexec("/usr/local/bin/wol -i {$bcip} {$mac}"); - $savemsg .= "Sent magic packet to {$mac}.<br>"; + /* Execute wol command and check return code. */ + if(!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}")){ + $savemsg .= "Sent magic packet to {$mac} ({$description}).<br>"; + } + else { + $savemsg .= "Please check the <a href=\"/diag_logs.php\">system log</a>, the wol command for {$description} ({$mac}) did not complete successfully.<br>"; + } } } @@ -82,9 +88,13 @@ if ($_POST || $_GET['mac']) { /* determine broadcast address */ $bcip = gen_subnet_max(get_interface_ip($if), get_interface_subnet($if)); - - mwexec("/usr/local/bin/wol -i {$bcip} {$mac}"); - $savemsg = "Sent magic packet to {$mac}."; + /* Execute wol command and check return code. */ + if(!mwexec("/usr/local/bin/wol -i {$bcip} {$mac}")){ + $savemsg .= "Sent magic packet to {$mac}."; + } + else { + $savemsg .= "Please check the <a href=\"/diag_logs.php\">system log</a>, the wol command for {$mac} did not complete successfully.<br>"; + } } } |