X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ocsinventory-agent-cn.git;a=blobdiff_plain;f=Hostname.pm;h=f35ae2c15209dfe54f3ea0c3aea67aceb7c4c3c5;hp=c1b5f310a89442d1e449fe28352fa00ef56b0dc3;hb=0173cf11e9654d7d16fdc4081ac033c2e8fc3a76;hpb=babaaceab2dc0c4760b9a776c46f60bae3f5f9d8 diff --git a/Hostname.pm b/Hostname.pm index c1b5f31..f35ae2c 100644 --- a/Hostname.pm +++ b/Hostname.pm @@ -1,26 +1,25 @@ package Ocsinventory::Agent::Backend::OS::Generic::Hostname; sub check { - eval { require (Sys::Hostname) }; - return 1 unless $@; - `which hostname 2>&1`; - return if ($? >> 8)!=0; - `hostname 2>&1`; - return if ($? >> 8)!=0; - 1; + return 1 if can_load ("Sys::Hostname::Long"); + return 1 if can_run ("hostname"); + 0; } # Initialise the distro entry sub run { my $params = shift; - my $inventory = $params->{inventory}; + my $common = $params->{common}; my $hostname; - # ico, Tue, 26 May 2009 17:58:27 +0200 - chomp ( my $hostname = `hostname --fqdn` ); + if (can_load("Sys::Hostname::Long")) { + $hostname = Sys::Hostname::Long::hostname_long(); + } else { + chomp ( $hostname = `hostname --fqdn` ); # TODO: This is not generic. + } - $inventory->setHardware ({NAME => $hostname}); + $common->setHardware ({NAME => $hostname}); } 1;