--- a/SI/system.pm Tue Jan 19 23:45:54 2010 +0100
+++ b/SI/system.pm Tue Jan 19 23:48:10 2010 +0100
@@ -9,31 +9,36 @@
$ENV{LC_ALL} = "C";
sub id() {
+
# hope it's eth* or wlan*
local $_ = (sort grep { /^(eth|wlan)/ } `ifconfig -a`)[0];
/^(?<dev>\S+)\s.*HWaddr\s+(?<mac>[\da-f:]+)\s*$/i
- and return $+{mac};
+ and return $+{mac};
die "ERR: Can't get system identification (MAC address)\n";
}
sub hostname(\%) {
- my $devs = shift;
- my $mnt = tempdir(CLEANUP => 1);
- my $r;
+ my $devs = shift;
+ my $mnt = tempdir(CLEANUP => 1);
+ my $r;
- foreach my $fs (grep { $devs->{volume}{$_}{type} =~ /^ext/i }
- grep { exists $devs->{volume}{$_}{type} }
- keys %{$devs->{volume}}) {
- run("mount -r $fs $mnt");
- if (-f "$mnt/etc/hostname") {
- die "ERR: found 2nd hostname" if defined $r;
- chomp($r = cat("$mnt/etc/hostname"));
- }
- run("umount $mnt");
- }
+ foreach my $fs (
+ grep { $devs->{volume}{$_}{type} =~ /^ext/i }
+ grep { exists $devs->{volume}{$_}{type} }
+ keys %{ $devs->{volume} }
+ )
+ {
+ run("mount -r $fs $mnt");
+ if (-f "$mnt/etc/hostname") {
+ die "ERR: found 2nd hostname" if defined $r;
+ chomp($r = cat("$mnt/etc/hostname"));
+ }
+ run("umount $mnt");
+ }
- return $r;
+ return $r;
}
1;
+
# vim:sts=4 sw=4 aw ai si: