SI/system.pm
changeset 8 2a66bb6a6a6e
child 15 4e3753b998a9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SI/system.pm	Sun Jan 17 00:00:02 2010 +0100
@@ -0,0 +1,20 @@
+package SI::system;
+
+use strict;
+use warnings;
+use if $ENV{DEBUG} ~~ qw(system) => "Smart::Comments";
+
+$ENV{LC_ALL} = "C";
+
+sub id($) {
+    my ($file) = @_;
+    open(my $f, ">$file") or die "Can't open $file: $!\n";
+    # hope it's eth*
+    local $_ = (sort grep { /^(eth|wlan)/ } `ifconfig -a`)[0];
+    return if not $_;
+    return if not /^(?<dev>\S+)\s.*HWaddr\s+(?<mac>[\da-f:]+)\s*$/i;
+    print $f "ethernet $+{dev} $+{mac}\n";
+}
+
+1;
+# vim:sts=4 sw=4 aw ai si: