Subversion Repositories camp_sysinfo_client_3

Rev

Rev 87 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 87 Rev 236
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
use strict;
3
use strict;
4
use warnings;
4
use warnings;
-
 
5
use Cwd 'abs_path';
-
 
6
use File::Basename;
5
 
7
 
6
our $VERSION = '1.1';
8
our $VERSION = '1.2';
7
 
9
 
8
# sysinfo module for sysinfo client
10
# sysinfo module for sysinfo client
9
# Author: R. W. Rodolico
11
# Author: R. W. Rodolico
10
# Date:   2016-04-08
12
# Date:   2016-04-08
11
# Grabs the version of the installed sysinfo-client
13
# Grabs the version of the installed sysinfo-client
12
#
14
#
13
# 20171124 RWR
15
# 20171124 RWR
14
# Modified for FreeBSD
16
# Modified for FreeBSD
-
 
17
#
-
 
18
# 20240519 RWR v1.2
-
 
19
# Assume sysinfo-client in parent directory, so just run it and have it tell us it's version
15
 
20
 
16
my @install = ( '/opt/camp/sysinfo-client', '/usr/local/opt/camp/sysinfo-client' );
21
# assume sysinfo-client is in our parent directory
17
 
-
 
18
my $installed;
22
my $sysinfo = dirname( abs_path( __FILE__ ) ) . '/../';
19
 
-
 
20
my $versionsFile = 'VERSION';
23
$sysinfo =  abs_path( $sysinfo ) . '/sysinfo-client';
21
 
-
 
22
foreach $installed ( @install ) {
24
# exit failure unless we can run it. Should never happen
23
   if ( -d $installed ) {
25
exit 1 unless ( -x $sysinfo );
24
      $versionsFile = $installed . '/' . $versionsFile;
26
# run it with the --version flag
25
   }
-
 
26
}
-
 
27
   
-
 
28
 
-
 
29
exit 1 unless -e $versionsFile;
27
my $output = `$sysinfo --version`;
-
 
28
chomp $output;
30
 
29
 
31
my $CATEGORY = 'software';
30
my $CATEGORY = 'software';
32
 
31
 
33
open FILE,"<$versionsFile" or exit 1;
-
 
34
my @line =  grep { /sysinfo-client/ } <FILE>;
-
 
35
close FILE;
-
 
36
 
-
 
37
chomp @line;
-
 
38
 
-
 
39
for ( my $i = 0; $i < @line; $i++ ) {
-
 
40
   my ($install, $version ) = split ' ', $line[$i];
32
my ($install, $version ) = split ' ', $output;
41
   if ( $install =~ m|.*/(.*)| ) { $install = $1; }
-
 
42
   print "$CATEGORY\t$install\tversion\t$version\n" if $install eq 'sysinfo-client';
33
print "$CATEGORY\t$install\tversion\t$version\n" if $install eq 'sysinfo-client';
43
}
34
 
-
 
35
exit 0;
44
 
36