Line | |
---|
1 | package Ocsinventory::Agent::Backend::OS::MacOS; |
---|
2 | |
---|
3 | use strict; |
---|
4 | |
---|
5 | require Exporter; |
---|
6 | our @ISA = qw /Exporter/; |
---|
7 | our @EXPORT = qw /get_sysprofile_devices_names/; |
---|
8 | |
---|
9 | |
---|
10 | sub check { |
---|
11 | my $r; |
---|
12 | # we check far darwin because that's the _real_ underlying OS |
---|
13 | $r = 1 if (uc($^O) =~ /^DARWIN$/); |
---|
14 | return($r); |
---|
15 | } |
---|
16 | |
---|
17 | sub run { |
---|
18 | my $params = shift; |
---|
19 | my $common = $params->{common}; |
---|
20 | |
---|
21 | my $OSName; |
---|
22 | my $OSComment; |
---|
23 | my $OSVersion; |
---|
24 | |
---|
25 | # if we can load the system profiler, gather the information from that |
---|
26 | if(can_load("Mac::SysProfile")){ |
---|
27 | my $profile = Mac::SysProfile->new(); |
---|
28 | my $data = $profile->gettype('SPSoftwareDataType'); |
---|
29 | return(undef) unless(ref($data) eq 'ARRAY'); |
---|
30 | |
---|
31 | my $h = $data->[0]; |
---|
32 | |
---|
33 | my $SystemVersion = $h->{'os_version'}; |
---|
34 | if ($SystemVersion =~ /^(.*?)\s+(\d+.*)/) { |
---|
35 | $OSName=$1; |
---|
36 | $OSVersion=$2; |
---|
37 | } else { |
---|
38 | # Default values |
---|
39 | $OSName="Mac OS X"; |
---|
40 | $OSVersion="Unknown"; |
---|
41 | } |
---|
42 | |
---|
43 | } else { |
---|
44 | # we can't load the system profiler, use the basic BSD stype information |
---|
45 | # Operating system informations |
---|
46 | chomp($OSName=`uname -s`); |
---|
47 | chomp($OSVersion=`uname -r`); |
---|
48 | } |
---|
49 | |
---|
50 | # add the uname -v as the comment, not really needed, but extra info never hurt |
---|
51 | chomp($OSComment=`uname -v`); |
---|
52 | $common->setHardware({ |
---|
53 | OSNAME => $OSName, |
---|
54 | OSCOMMENTS => $OSComment, |
---|
55 | OSVERSION => $OSVersion, |
---|
56 | }); |
---|
57 | } |
---|
58 | |
---|
59 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.