Subversion Repositories camp_sysinfo_client_3

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
41 rodolico 1
#!/usr/bin/env perl
2
 
3
use strict;
4
use warnings;
5
 
6
our $VERSION = '1.1';
7
 
8
# sysinfo module for sysinfo client
9
# Author: R. W. Rodolico
10
# Date:   2016-04-08
11
# Grabs the version of the installed sysinfo-client
57 rodolico 12
#
13
# 20171124 RWR
14
# Modified for FreeBSD
41 rodolico 15
 
57 rodolico 16
my @install = ( '/opt/camp/sysinfo-client', '/usr/local/opt/camp/sysinfo-client' );
41 rodolico 17
 
57 rodolico 18
my $installed;
19
 
20
my $versionsFile = 'VERSION';
21
 
22
foreach $installed ( @install ) {
23
   if ( -d $installed ) {
24
      $versionsFile = $installed . '/' . $versionsFile;
25
   }
26
}
27
 
28
 
41 rodolico 29
exit 1 unless -e $versionsFile;
30
 
31
my $CATEGORY = 'software';
32
 
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];
41
   if ( $install =~ m|.*/(.*)| ) { $install = $1; }
42
   print "$CATEGORY\t$install\tversion\t$version\n" if $install eq 'sysinfo-client';
43
}