SI/system.pm
changeset 15 4e3753b998a9
parent 8 2a66bb6a6a6e
child 16 fd87c1e3b451
equal deleted inserted replaced
14:aecda2763079 15:4e3753b998a9
     4 use warnings;
     4 use warnings;
     5 use if $ENV{DEBUG} ~~ qw(system) => "Smart::Comments";
     5 use if $ENV{DEBUG} ~~ qw(system) => "Smart::Comments";
     6 
     6 
     7 $ENV{LC_ALL} = "C";
     7 $ENV{LC_ALL} = "C";
     8 
     8 
     9 sub id($) {
     9 sub id() {
    10     my ($file) = @_;
    10     # hope it's eth* or wlan*
    11     open(my $f, ">$file") or die "Can't open $file: $!\n";
       
    12     # hope it's eth*
       
    13     local $_ = (sort grep { /^(eth|wlan)/ } `ifconfig -a`)[0];
    11     local $_ = (sort grep { /^(eth|wlan)/ } `ifconfig -a`)[0];
    14     return if not $_;
    12     /^(?<dev>\S+)\s.*HWaddr\s+(?<mac>[\da-f:]+)\s*$/i
    15     return if not /^(?<dev>\S+)\s.*HWaddr\s+(?<mac>[\da-f:]+)\s*$/i;
    13     	and return $+{mac};
    16     print $f "ethernet $+{dev} $+{mac}\n";
    14     die "ERR: Can't get system identification (MAC address)\n";
    17 }
    15 }
    18 
    16 
    19 1;
    17 1;
    20 # vim:sts=4 sw=4 aw ai si:
    18 # vim:sts=4 sw=4 aw ai si: