X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=Hostname.pm;h=c576c588c1adf5335a0e2e85437dc27808092e7f;hb=HEAD;hp=e641d8dd6744a7e991dc330c2521f2de20209728;hpb=be014671d2dc4deaf3238e3828d26a23b9b40e1a;p=ocsinventory-agent-cn.git diff --git a/Hostname.pm b/Hostname.pm index e641d8d..c576c58 100644 --- a/Hostname.pm +++ b/Hostname.pm @@ -1,34 +1,22 @@ 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; + my $params = shift; + my $common = $params->{common}; + return 1 if $common->can_run ("hostname"); + 0; } # Initialise the distro entry sub run { - my $params = shift; - my $inventory = $params->{inventory}; + my $params = shift; + my $common = $params->{common}; - my $hostname; + my $hostname; - # ico, Tue, 26 May 2009 17:58:27 +0200 - chomp ( my $hostname = `hostname --fqdn` ); - #eval { require (Sys::Hostname) }; - #if (!$@) { - # $hostname = Sys::Hostname::hostname(); - #} else { - # chomp ( $hostname = `hostname` ); # TODO: This is not generic. - #} - #$hostname =~ s/\..*//; # keep just the hostname + chomp ( $hostname = `hostname -f` ); # TODO: This is not generic. - - $inventory->setHardware ({NAME => $hostname}); + $common->setHardware ({NAME => $hostname}); } 1;