ispravke u postinst/postrm
[ocsinventory-agent-cn.git] / Hostname.pm
1 package Ocsinventory::Agent::Backend::OS::Generic::Hostname;
2
3 sub check {
4   eval { require (Sys::Hostname) };
5   return 1 unless $@;
6   `which hostname 2>&1`;
7   return if ($? >> 8)!=0;
8   `hostname 2>&1`;
9   return if ($? >> 8)!=0;
10   1;
11 }
12
13 # Initialise the distro entry
14 sub run {
15   my $params = shift;
16   my $inventory = $params->{inventory};
17
18   my $hostname;
19
20   # ico, Tue, 26 May 2009 17:58:27 +0200
21   chomp ( my $hostname = `hostname --fqdn` );
22   #eval { require (Sys::Hostname) };
23   #if (!$@) {
24   #  $hostname = Sys::Hostname::hostname();
25   #} else {
26   #  chomp ( $hostname = `hostname` ); # TODO: This is not generic.
27   #}
28   #$hostname =~ s/\..*//; # keep just the hostname
29
30
31   $inventory->setHardware ({NAME => $hostname});
32 }
33
34 1;