diff -r fd87c1e3b451 -r d4942418a9ea SI/system.pm --- 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]; /^(?\S+)\s.*HWaddr\s+(?[\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: