Save energy and put your unused computers immediately to sleep if they support power-saving mode (most do) then wake them up when you need to connect remotely. If you have lots of devices to manage then this guide might be useful.
Not only that, some internet or mobile connections doesn’t support WOL because the UDP port (usually UDP port 9) to forward the magic packet is blocked. I’ve encountered several times that WOL apps doesn’t work because of this even when I’ve already opened the UDP port in my router. The only way is to connect (i.e. via SSH) into one of your waked device and issue the wake command manually to the computer you need to wakeup.
To ease this process, setup WOL web access on your NAS, in this case the WDMyCloud. You’ll need to ensure your computers are able to wake up by magic packets. Go to your network adapter properties in the “Device Manager” and make sure your LAN adapter is allowed to wake the computer. Note that these wake up settings might revert to default if you update/downgrade your LAN adapter drivers or upgrade/restore your OS.
Then setup your computer to sleep after a while in the “Power Options” found in the “Control Panel”. Also change the power button to sleep instead of shutdown to quickly put it to sleep. Note that these power options might revert to default if you upgrade/restore your OS.
Next is to install my universal “wol.pl” Perl script in a webserver. It works for any webserver with Perl-CGI in this case Apache2 which is the pre-installed webserver in WDMyCloud. This requires modifications to the WDMyCloud Apache2 webserver. But if you’re not comfortable doing this yourself, you can also perform the automated install of Nginx from my post WebHosting on WDMyCloud V4 Firmwares and then symlink the “wol.pl” Perl script to your installed Nginx’s webroot path. Symlink sample is stated at the last point. Note, if you have installed Nginx from my “WebHosting Mods” installer post link above, do not modify Apache2’s configurations as below because it’s using a different incompatible “MPM_Event” module! Instead just follow the part where it doesn’t involves Apache2 changes.
Disclaimer: As I’m frequently updating the original guides and installers here on TeaNazaR.com, I will not be responsible for any brick issues if you were to follow my obsolete guides copied elsewhere. Thus subscribe to this post to get latest updates. Modifying any part of a device may void its warranty.
Modifications to WDMyCloud WebServer to enable Perl CGI
Open TCP port 80 on your router to the WDMyCloud, similarly you would have done for SSH port 22 and FTP port 21. This depends on your router, search online on how to do it for your specific router, if necessary. If you’re lucky, the port 80 maybe already selected and opened in the WDMyCloud Dashboard. For Nginx, note the port route stated in my guide was Router:80 -> WDMyCloud:5080.
For Apache2, create a new CGI config file nano /etc/apache2/conf.d/cgi.conf then copy & paste below:
1 2 3 4 5 6 7 8 9 | <IfModule mod_cgi.c> AddHandler cgi-script .cgi .pl <Files ~ "\.pl$"> Options +ExecCGI </Files> <Files ~ "\.cgi$"> Options +ExecCGI </Files> </IfModule> |
Then “CTRL+x” to exit and “y” to save.
Enable the Apache2 CGI module, issue a2enmod cgi then reload Apache2 server daemon, issue service apache2 reload . Remember once again to skip the above if you already have Nginx installed from my installer.
Copy the “wol.pl” Perl script found at the bottom of this post to any path on your WDMyCloud, give it an executable permission chmod 755 /shares/scripts/wol.pl and HTTPD ownership chown www-data:www-data /shares/scripts/wol.pl.
It’s recommended to hide the script from public, best password protected, path e.g. here ./private/. This method is also applicable if you had installed Nginx from my installer except the default webroot for Nginx is cd /var/www/html/ and Apache is cd /var/www/htdocs/. After changing to the appropriate webroot path above, now create a new ./private/ folder in the webroot, issue mkdir -pm755 ./private/. Then password protect the path for user e.g. “username”, issue htpasswd -c ./private/.htpasswd username and enter a “password”, enter again to confirm.
Next is to enable the access control for this path.
For Apache2, create a new “.htaccess” file, nano /var/www/htdocs/private/.htaccess then copy & paste below:
1 2 3 4 | AuthType Basic AuthName "Authentication Required" AuthUserFile /var/www/htdocs/private/.htpasswd Require valid-user |
For Nginx, instead of “.htaccess” file, add below to your server directive config i.e. nano /etc/nginx/sites-enabled/default:
1 2 | auth_basic "Authentication Required"; auth_basic_user_file /var/www/html/private/.htpasswd; |
Then reload Nginx server daemon, issue service nginx reload. For either above, remember to “CTRL+x” to exit and “y” to save.
And finally, symlink the original “wol.pl” Perl script you had created earlier to the webserver’s webroot, issue ln -s /shares/scripts/wol.pl ./private/.
Now to wakeup your computer, simply access the script on your webserver e.g. http://wdmycloud.your.isp.ip.or.domain/private/wol.pl then login using the “username” and “password” you had created earlier. How to remember your dynamic ISP address? Checkout the first part of my post in WebHosting on WDMyCloud V4 Firmwares.
Enjoy (-:
wol.pl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | #!/usr/bin/perl use strict; use warnings; use IO::Socket; # wol.pl v1.5 by Nazar78 @ TeaNazaR.com ####################################### # Simple Unix/Windows WakeOnLAN CGI script. # It scans your arp list to display available device on the LAN. # You can add/remove devices or wake them up from the saved list. # # Requirements: # - A webserver i.e. IIS/Apache/Nginx with Perl-CGI. # - Unix (ifconfig/ping/arp) or Windows (ipconfig/ping/arp). # - Unix user running Perl-CGI i.e. 'www-data' needs sudo access i.e.: # /etc/sudoers:www-data ALL=(ALL) NOPASSWD: ALL # # History: # v1.0 - 20141105 - 1st release. # v1.1 - 20151004 - Enhanced the webUI to manually add new device. # v1.2 - 20151112 - Added pings for offline hosts to help build arp list. # v1.3 - 20160520 - Fixed UDP input on certain browsers. Display saved hosts over active IPs. # v1.4 - 20190722 - Fixed finding MAC address for Unix chroot environments. # v1.5 - 20210122 - Fixed warnings appearing in logs. # # PS: Feel free to distribute but kindly retain the credits (-: ####################################### # Begin Settings # UDP port to send magic packet. my $udpPort = 9; # Manually add Hostname|MAC per-line eg. MyRoomPC|00:00:00:00:00:00 my $devices = q/ MyRoomPC|00:00:00:00:00:00 MyRoomLaptop|00:00:00:00:00:00 /; # End Settings my $program = 'wol.pl v1.5 by Nazar78 @ TeaNazaR.com'; $| = 1; my $query = 0; my %queries = (); my %hosts = (); my %deviceExists = (); my @devices = (); foreach my $mac (split(/\n/, $devices)) { chomp $mac; my ($host, $mac) = split(/\|/, $mac); $host = '' if !$host; $mac = '' if !$mac; $mac =~ s/\-/\:/g; $mac = lc $mac; next if !isMAC($mac); push @devices, "$host|$mac"; $hosts{$mac} = $host; } &getQueries; my @list = (); if (open(FILE, '<', $ENV{SCRIPT_FILENAME})) { @list = <FILE>; close(FILE); } else { error("Error#2: Unable to read $ENV{SCRIPT_FILENAME}!"); } my $lines = ''; foreach my $line (@list) { if ($line =~ /^#(.*)/ && $line !~ /^#\!/) { last if $line =~ /^#\sBegin\s/; $lines .= "$1\\n\\\n"; } } print "Pragma: no-cache\n" . "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0\n" . "Expires: Sat, 8 Jul 1978 00:00:00 GMT\nContent-type: text/html\n\n" . qq|<html> <head> <meta name="viewport" content="width=500, initial-scale=.72"> <title>::[$program]::</title> <style> * {font-family:Arial;} input { box-shadow: 3px 3px 3px #888888; -moz-border-radius-bottomleft:5px; -webkit-border-bottom-left-radius:5px; border-bottom-left-radius:5px; -moz-border-radius-bottomright:5px; -webkit-border-bottom-right-radius:5px; border-bottom-right-radius:5px; -moz-border-radius-topright:5px; -webkit-border-top-right-radius:5px; border-top-right-radius:5px; -moz-border-radius-topleft:5px; -webkit-border-top-left-radius:5px; border-top-left-radius:5px; font-weight:bold; text-decoration:none; font-style:italic; } input[type='number'] { -moz-appearance:textfield; } input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; } .wol { position:absolute; white-space:nowrap; width:480px; margin:0px;padding:0px; box-shadow: 10px 10px 5px #888888; border:1px solid #e5e5e5; -moz-border-radius-bottomleft:14px; -webkit-border-bottom-left-radius:14px; border-bottom-left-radius:14px; -moz-border-radius-bottomright:14px; -webkit-border-bottom-right-radius:14px; border-bottom-right-radius:14px; -moz-border-radius-topright:14px; -webkit-border-top-right-radius:14px; border-top-right-radius:14px; -moz-border-radius-topleft:14px; -webkit-border-top-left-radius:14px; border-top-left-radius:14px; } .wol:before { content:""; position:absolute; top:0; left:0; width:100%; height:100%; z-index:-1; opacity:0.3; filter:alpha(opacity=30); background-image:url("data:image/png;base64,\\ iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB\\ oElEQVRYhe3WvYsTQRiA8d+aRI6DQJAgcoWIpjqwsRQ5xELPg4CItVx1lYVYC0lnIVZGCPgvWAgW\\ fhR+oIWt1qYQ0dYcRgQFxyJzso4H2Q0esdi32ZlnZt55dnZ2mCyEYJGxb6GzVwKVwP8gUId+vz+r\\ 3xoO4t4/nLvTbDY3shCCLMtmdV7HHRzbrbFWq2m32xqNBhiPxyaTyayc17vd7nEFD6JlfEOnSOeC\\ 8XIwGGwWFYDHuJKwI1hCy3SVTomfNbKNyNK91sKP0Wi0UkbgGh4kLOAWtvE11l9Emc859iwnBhfx\\ JoSgjMAqvmB/IrCNk7F+ObKPOBHZVmRncuPu4mZZAXifJAq4nasvRXYjx1qRbaZ5Qgilz4EnOJ+w\\ Ua78PT4/7MJ2YhUH8IryB9FDnE3Yz5I51vF8R6yswFPTN1gpOS4f50z/KPMIjPHa36tQNJZNT9VH\\ 8wowtU/3QdFYwye8+03muJJ1cDWWL+Bo0p6yemSHcRqX/ph7kXfCEIL6cDjcwqEZfd/i/l5I1KHX\\ 6+1F7kKRVdfySqASqAQWLfALtF13Mn0mOo4AAAAASUVORK5CYII="); } .wol table { opacity:0.8; filter:alpha(opacity=80); width:480px; border-collapse: collapse; border-spacing: 0; margin-top:6px; padding:0px; } .wol tr:last-child td:last-child { -moz-border-radius-bottomright:14px; -webkit-border-bottom-right-radius:14px; border-bottom-right-radius:14px; } .wol table tr:first-child td:first-child { -moz-border-radius-topleft:14px; -webkit-border-top-left-radius:14px; border-top-left-radius:14px; } .wol table tr:first-child td:last-child { -moz-border-radius-topright:14px; -webkit-border-top-right-radius:14px; border-top-right-radius:14px; } .wol tr:last-child td:first-child { -moz-border-radius-bottomleft:14px; -webkit-border-bottom-left-radius:14px; border-bottom-left-radius:14px; } .wol tr:hover td {background:#e5ffff; } .wol tr:nth-child(odd) { background-color:#e5e5e5; } .wol tr:nth-child(even) { background-color:#ffffff; } .wol td { vertical-align:middle; border:1px solid #e5ffff; border-width:0px 1px 1px 0px; text-align:left; padding:7px; font-size:13px; font-family:Arial; font-weight:normal; color:#000000; } .wol tr:last-child td { border-width:0px 1px 0px 0px; } .wol tr td:last-child { border-width:0px 0px 1px 0px; } .wol tr:last-child td:last-child { border-width:0px 0px 0px 0px; } .wol tr:first-child td { background:-o-linear-gradient(bottom,#4c4c4c 5%,#4c4c4c 100%); background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#4c4c4c),color-stop(1,#4c4c4c)); background:-moz-linear-gradient(center top,#4c4c4c 5%,#4c4c4c 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#4c4c4c",endColorstr="#4c4c4c"); background: -o-linear-gradient(top,#4c4c4c,4c4c4c); background-color:#4c4c4c; border:0px solid #e5e5e5; text-align:center; border-width:0px 0px 1px 1px; font-size:13px; font-family:Arial; font-weight:bold; color:#ffffff; } .wol tr:first-child:hover td { background:-o-linear-gradient(bottom, #4c4c4c 5%,#4c4c4c 100%); background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#4c4c4c),color-stop(1,#4c4c4c)); background:-moz-linear-gradient(center top, #4c4c4c 5%, #4c4c4c 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#4c4c4c",endColorstr="#4c4c4c"); background: -o-linear-gradient(top,#4c4c4c,4c4c4c); background-color:#4c4c4c; } .wol tr:first-child td:first-child { border-width:0px 0px 1px 0px; } .wol tr:first-child td:last-child { border-width:0px 0px 1px 1px; } </style> <script> function deviceRemove(x) { if (confirm('This device is offline and will not be shown again' + ' if removed from the saved list. Are you sure?')) document.location.href = x; }; function deviceAdd(x, y, z) { x = x.replace(/\\s/g, ''); y = y.replace(/\\s/g, ''); z = z.replace(/\\s/g, ''); if (!z) { document.getElementById('mac').style.backgroundColor = 'red'; document.getElementById('mac').style.color = 'white'; wol.mac.focus(); } else { var host = prompt('Add a hostname or IP to identify this device?', y); if (host != null) { host = host.replace(/\\s/g, ''); if (host.length > 255) error('Error#0: Hostname max length is 255 ' + host + '!'); else if (host == '') { document.getElementById('device').style.backgroundColor = 'red'; document.getElementById('device').style.color = 'white'; wol.device.focus(); } else document.location.href = x + host + '&mac=' + z; } } }; function help() { alert("$lines"); } function error(x) { alert(x) }; </script> </head> <body> <form method='get' name='wol'> <div class='wol'><br> <div style='white-space:nowrap;margin-top:3px;text-align:center;color:#4c4c4c'> <b>::[$program]::</b></div> <span style='background:white;color:blue;font-size:13px;margin-left:10px'> |; $udpPort = $queries{port} if ($queries{port} && int($queries{port})); if ($queries{list} && $queries{list} ne '') { if ($queries{mac} && $queries{mac} ne '') { $queries{mac} =~ s/\-/\:/g; $queries{mac} = lc $queries{mac}; if (isMAC($queries{mac})) { $query = 1; $queries{host} = 'Unknown' if !$queries{host}; my $trimHost = $queries{host}; $trimHost = substr($trimHost, 0, 15) . '...' if length($trimHost) > 15; if ($queries{list} eq 'add') { push @devices, "$queries{host}|$queries{mac}"; $hosts{$queries{mac}} = $queries{host}; print "$trimHost ($queries{mac}) added to saved list!<br>\n"; } elsif ($queries{list} eq 'remove') { @devices = grep { $_ !~ /$queries{mac}/ } @devices; print "$trimHost ($queries{mac}) removed from saved list!<br>\n"; } my %seen = (); @devices = grep { ! $seen{ $_ }++ } @devices; if (open(FILE, '>', $ENV{SCRIPT_FILENAME})) { my $devUpdate = 0; foreach my $line (@list) { chomp $line; if ($line eq 'my $devices = q/') { $devUpdate = 1; print FILE 'my $devices = q/' . "\n" . join("\n", @devices) . "\n" . '/;' . "\n"; } elsif ($devUpdate && $line eq '/;') { $devUpdate = 0; } elsif (!$devUpdate) { print FILE "$line\n"; } } close(FILE); } else { error("Error#1: Unable to write $ENV{SCRIPT_FILENAME}!"); } } else { error("Error#3: Invalid MAC $queries{mac}!"); } } } elsif ($queries{mac} && $queries{mac} ne '') { $query = 1; $queries{mac} =~ s/\-/\:/g; $queries{mac} = lc $queries{mac}; my $broadcast = ($queries{device} && $queries{device} ne '' ? 0:1); print "Sending magic packet to " . ($broadcast ? '255.255.255.255':$queries{device}) . ":$udpPort with $queries{mac}..."; if (!isMAC($queries{mac})) { error("Error#3: Invalid MAC $queries{mac}!"); } elsif (my $sock = new IO::Socket::INET(Proto=>'udp')) { my $ip = inet_aton($broadcast ? '255.255.255.255':$queries{device}) || do { error("Error#4: Invalid device $queries{device}!"); goto err; }; my $addr = sockaddr_in($udpPort, $ip) || do { error("Error#5: $!"); goto err; }; if ($broadcast && !setsockopt($sock, SOL_SOCKET, SO_BROADCAST, 1)) { error("Error#6: $!"); goto err; } my $mac = ''; foreach (split(/:/, $queries{mac})) { $mac .= chr(hex($_)); } if (send($sock, chr(0xFF) x 6 . $mac x 16, 0, $addr)) { print "Done!<br>\n"; } else { error("Error#7: $!"); } err: close($sock); } else { error("Error#8: $!"); } } my $b1 = ''; my $b2 = ''; my $list = ''; my $arp = ''; my $addr = ''; print "<br>\n" if !$query; print "</span><table><tr><td><b>Host</b></td><td><b>IP</b></td>" . "<td><b>MAC</b></td><td><b>State</b></td><td><b>List</b></td></tr>\n"; if ($^O eq 'MSWin32') { $arp = 'arp'; $addr = `ipconfig/all | findstr Physical` || error("Error#9: Can\\'t execute ipconfig command!"); foreach my $lists (split(/\n/, $addr)) { chomp $lists; next if $lists eq ''; $lists =~ s/.+ : (.+)$/$1/g; $lists =~ s/\-/\:/g; $lists = lc $lists; next if !isMAC($lists); $deviceExists{lc $lists} = 1; } } else { if (-x '/usr/sbin/arp') { $arp = '/usr/sbin/arp'; } elsif (-x '/sbin/arp') { $arp = '/sbin/arp'; } else { error("Error#10: Can\\'t find arp command!"); } $arp = "sudo $arp"; if (-x '/sbin/ifconfig') { $addr = '/sbin/ifconfig'; } elsif (-x '/usr/sbin/ifconfig') { $addr = '/usr/sbin/ifconfig'; } else { error("Error#10: Can\\'t find ifconfig command!"); } $addr = `sudo $addr` || error("Error#9: Can\\'t execute ifconfig command!"); foreach my $lists (split(/\n/, $addr)) { chomp $lists; next if $lists eq ''; $lists =~ s/.*([\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}).*/$1/g; $lists = lc $lists; next if !isMAC($lists); $deviceExists{lc $lists} = 1; } } foreach my $device (@devices) { my ($host, $device) = split(/\|/, $device); ping($host) if $host ne ''; } $arp = `$arp -a` || error("Error#9: Can\\'t execute arp command!"); foreach my $device (split(/\n/, $arp)) { chomp $device; next if $device eq ''; $device =~ s/[\(\)]//g; $device =~ s/\s+/ /g; my ($host, $ip, $mac, $type) = (); if ($^O eq 'MSWin32') { (undef, $ip, $mac, $type) = split(/ /, $device); next if $type eq 'static'; $mac =~ s/\-/\:/g; } else { (undef, $ip, undef, $mac) = split(/ /, $device); } next if !isMAC($mac) || $deviceExists{$mac}; $host = gethostbyaddr(inet_aton($ip), AF_INET) or $host = $hosts{lc $mac} or $host = $ip; if ($host eq $ip && $hosts{lc $mac}) { $host = $hosts{lc $mac}; } my $wol = 'Awake'; my $alive = ping($ip); $wol = "<a href='?device=$ip&mac=$mac&id=" . time . "' style='cursor:pointer'><u>WOL</u>?</a>" if $alive eq ''; if (grep(/$mac/, @devices)) { $b1 = '<b>'; $b2 = '</b>'; my $url = "\"?list=remove&host=$host&mac=$mac&id=" . time . "\""; my $confirm = "document.location.href=$url"; $confirm = "deviceRemove($url)" if $alive eq ''; $list = "<a onclick='$confirm' style='cursor:pointer'><u>Remove</u>?</a>"; } else { $b1 = ''; $b2 = ''; $list = "<a onclick='deviceAdd(\"?list=add&id=" . time . "&host=\", \"$host\", \"$mac\")' style='cursor:pointer'><u>Add</u>?</a>"; } my $trimHost = $host; $trimHost = substr($trimHost, 0, 15) . '...' if length($trimHost) > 15; print "<tr><td>$b1$trimHost$b2</td><td>$b1$ip$b2</td>" . "<td>$b1$mac$b2</td><td>$b1$wol$b2</td><td>$b1$list$b2</td></tr>\n"; $deviceExists{lc $mac} = 1; } foreach my $device (@devices) { my ($host, $device) = split(/\|/, $device); my $trimHost = $host; $trimHost = substr($trimHost, 0, 15) . '...' if length($trimHost) > 15; print "<tr><td><b>$trimHost</b></td><td><b>?</b></td>" . "<td><b>$device</b></td><td><a href='?mac=$device&id=" . time . "' style='cursor:pointer'><b><u>WOL</u>?</b></a></td>" . "<td><a onclick='deviceRemove(\"?list=remove&host=$host&mac=$device&id=" . time . "\")' style='cursor:pointer'><b><u>Remove</u>?</b></a></td></tr>\n" if !$deviceExists{$device}; } print "<tr><td colspan='5' id='device'><b> Host/IP</b> : " . "<input type='text' name='device' size='13' style='width:125px'> " . "<font size='1'>Leave blank to broadcast or a hostname/IP to wake/add.</font></td></tr>\n" . "<tr><td colspan='5' id='mac'><b> MAC</b> : " . "<input type='text' name='mac' size='15' style='width:140px'> " . "<font size='1'>Leave blank to refresh or a MAC to wake/add.</font></td></tr>\n" . "<tr><td colspan='5'><b> UDP Port</b> : " . "<input type='number' name='port' value=$udpPort size='1' style='width:23px'> " . "<input type='submit' value='Refresh or WOL?' style='cursor:pointer'> " . "<input type='button' value='Add Device?' style='cursor:pointer' onclick='deviceAdd(\"?list=add&id=" . time . "&host=\", wol.device.value, wol.mac.value)'>" . "<input type='button' value=' ? ' onclick='help()' style='position:absolute;right:7px;bottom:7px;cursor:pointer'>" . "<input type='hidden' name='id' value='" . time . "'></td></tr>\n" . "</table></div></form></body></html>\n"; sub getQueries { if ($ENV{QUERY_STRING} && $ENV{QUERY_STRING} ne '') { foreach my $var (split(/&/, $ENV{QUERY_STRING})) { my ($name, $value) = split(/=/, $var); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\s//g; $queries{$name} = $value; } } } sub ping { my $ip = shift; if ($^O eq 'MSWin32') { $ip = `ping -w 100 -n 1 $ip 2>nul | findstr from`; } else { $ip = `sudo ping -W1 -c1 $ip 2>/dev/null | grep from`; } return $ip; } sub error { print "<script>error('" . shift . "')</script>"; } sub isMAC { return 1 if shift =~ /^[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}$/; } |
wol.pl Updated!
v1.2 – 20151112 – Added pings for offline hosts to help build arp list.
wol.pl Updated!
v1.3 – 20160520 – Fixed UDP input on certain browsers. Display saved hosts over active IPs.
Another source about WOL for myCloud says that “older” version of MyCloud don’t support WOL. I have tried other WOL solutions (just sending broadcasting the magic packet 255.255.255.0 and other similar ideas) but haven’t had any luck so far.
Is there some command I can issue to determine if my 4TB MyCloud Firmware V4* will do WOL?
(What a great resource you are!)
Thanks
Neil
Chicago, IL
Hello Neil,
This variant of MyCloud does not support WOL. The post is about setting up to wake up other devices within the network that support WOL.
Nazar,
Thanks very much for clarifying. At least I won’t spend any more time trying to get WOL to work!
Neil
Chicago, Illinois
Hello Neil,
No problem, do let me know if you need any other help 🙂
This is awesome Nazar!!!
Do you think you can provide some guidance on how to apply your script to a RPi with already installed with nginx?
Hello egas,
Firstly you’ll need to setup some stuffs…
Get the fcgi wrapper:
wget http://nginxlibrary.com/downloads/perl-fcgi/fastcgi-wrapper -O /usr/bin/fastcgi-wrapper.pl
Get the fcgi service starter:
wget http://nginxlibrary.com/downloads/perl-fcgi/perl-fcgi -O /etc/init.d/perl-fcgi
Give executable permission to the files above:
chmod +x /usr/bin/fastcgi-wrapper.pl /etc/init.d/perl-fcgi
Setup perl-fcgi to run on boot:
update-rc.d perl-fcgi defaults
Start the perl-fcgi service:
service perl-fcgi start
Add below to your nginx’s config:
location ~ \.pl|cgi$ {
fastcgi_pass 127.0.0.1:8999;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Reload nginx:
service nginx reload
Then finally place my script anywhere in your nginx’s www root.