Skip to content

Add wakeonlan 0.41 #124

Merged
merged 2 commits into from
Sep 15, 2016
Merged

Add wakeonlan 0.41 #124

merged 2 commits into from
Sep 15, 2016

Conversation

pmenzel
Copy link
Collaborator

@pmenzel pmenzel commented Sep 14, 2016

Sends 'magic packets' to wake-on-LAN enabled ethernet adapters

Donald wrote a similar script.

$ more /project/admin/tools/wake
#! /usr/local/bin/perl -w
use strict;
use IO::Socket::INET;

@ARGV==1 or die "usage: $0 name|ip|ether\n";

our $ether;
our $ip;

if ($ARGV[0]=~/^([a-z0-9]{1,2}:){5}[a-z0-9]{1,2}$/) {
    $ether=$ARGV[0];
} else {
    our %last_ether;

    open DB,'<','/home/buczek/pcap/arplisten/arplisten.out' or die "/home/buczek/pcap/arplisten/arplisten.out: $!\n";
    while(<DB>) {
        my ($ether,$name)=split;
        my ($timestamp,$ip)=/# arp seen time=(.+) ip=(.+)/;
                if (!exists $last_ether{$ip} || $last_ether{$ip}->[0] lt $timestamp)
                {
            $last_ether{$ip} = [$timestamp,$ether];
                }
        }
        close DB;

    if ($ARGV[0]=~/^\d/) {
        $ip=($ARGV[0]); 
    } else {
        my $pa=gethostbyname($ARGV[0]); # ($ARGV[0]);
        defined $pa or die "$ARGV[0]: unknown host\n";
        $ip=join('.',unpack('C*',$pa));
    }
    exists $last_ether{$ip} or die "$ip: no ethernet address recorded\n";
    $ether=$last_ether{$ip}->[1];
}


my $s=new IO::Socket::INET (Proto=>'udp',Broadcast=>1);
defined $s or die "$!\n";

my $data=pack('C*',(255)x6, (map(hex,split(':',$ether))) x16);
warn "broadcast wake message to $ether\n";
$s->send($data,0,pack_sockaddr_in(9,inet_aton('141.14.31.255'))) or die "$!\n";

Other alternatives exist.

Debian package description [1]:

> Sends 'magic packets' to wake-on-LAN enabled ethernet adapters
>
> With this package you can remotely wake up and power on machines which
> have motherboards or network cards that support 'Wake-on-Lan' packets.
>
> The tool allows you to wake up a single machine, or a group of machines.
>
> You need the MAC addresses of machines to construct the WOL packets,
> but, in contrast to 'etherwake', you do not need root privileges to use
> the program itself as UDP packets are used.

As the upstream project Web site [2] is not accessible anymore, and the
source cannot be downloaded from there, use the source archive from the
Debian server.

The page *Wake on LAN* in the ubuntuusers Wiki documents everything
quite well [3].

The network device on the Dell OptiPlex 7010 is set up correctly by
default, so could be stared over the LAN without any issues.

[1] https://packages.debian.org/sid/wakeonlan
[2] http://gsd.di.uminho.pt/jpo/software/wakeonlan/
[3] https://wiki.ubuntuusers.de/Wake_on_LAN/
Fix bee’s conflict warning below, by removing the file `perllocal.pod` from the
package. Normally, Perl modules append their section there, when installed.

```
[BEE] changing to image directory: /dev/shm/bee-root/wakeonlan/wakeonlan-0.41-0/image
[BEE]  -> creating package wakeonlan-0.41-0.x86_64.bee.tar.bz2 ..
[BEE] /src/mariux/beeroot/packages/wakeonlan-0.41-0.x86_64.bee.tar.bz2
-rw-r--r-- root/system    2098 2016-09-14 15:40 CONTENT
-rwxr-xr-x root/system    2631 2016-09-14 15:40 BUILD
-rw-r--r-- root/system     439 2016-09-14 15:40 META
-r--r--r-- root/system    4588 2016-09-14 15:40 /usr/local/share/man/man1/wakeonlan.1
-r-xr-xr-x root/system    5237 2016-09-14 15:40 /usr/local/bin/wakeonlan
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/site_perl/
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/site_perl/5.12.1/
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/site_perl/5.12.1/x86_64-linux-thread-multi/
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/site_perl/5.12.1/x86_64-linux-thread-multi/auto/
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/site_perl/5.12.1/x86_64-linux-thread-multi/auto/wakeonlan/
-rw-r--r-- root/system     163 2016-09-14 15:40 /usr/local/lib/perl5/site_perl/5.12.1/x86_64-linux-thread-multi/auto/wakeonlan/.packlist
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/5.12.1/
drwxr-xr-x root/system       0 2016-09-14 15:40 /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/
-rw-r--r-- root/system     242 2016-09-14 15:40 /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] -> saving bee-file wakeonlan.be0 ..
[BEE] /src/mariux/beeroot/bee-files/wakeonlan-0.41-0.bee
‘/home/pmenzel/bee-files/./wakeonlan.be0’ -> ‘/src/mariux/beeroot/bee-files/wakeonlan-0.41-0.bee’
[BEE] Conflicts with installed package found: Donald-1.03-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: IO-Tty-1.10-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: Linux-Inotify2-1.22-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: Mojolicious-2.36-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: Term-ReadLine-Gnu-1.20-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: Time-Period-1.24-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: Tk-804.029-0.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
[BEE] Conflicts with installed package found: subversion-1.6.16-1.x86_64:
[BEE]     /usr/local/lib/perl5/5.12.1/x86_64-linux-thread-multi/perllocal.pod
```
@donald donald merged commit 7a826e2 into master Sep 15, 2016
@donald donald deleted the add-wakeonlan-0.41 branch September 26, 2016 13:58
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants