Subversion Repositories camp_sysinfo_client_3

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
59 rodolico 1
#! /usr/bin/env perl
2
 
3
use warnings;
4
use strict;
5
 
6
my $clientName = '';
7
my $serialNumber = '';
8
my $hostname = '';
9
my $UUID = '';
10
my @moduleDirs = ();
11
my @scriptDirs = ();
12
my $transports;
13
 
14
my $input = shift;
15
 
16
open CONF,"<$input" or die "could not open $input for read: $!\n";
17
my $conf = join( '', <CONF> );
18
close CONF;
19
 
20
eval( $conf );
21
 
22
$UUID = &getUUID() unless $UUID;
23
$serialNumber = &getSerial unless $serialNumber;
24
 
25
print "\$configuration{'clientName'} = '$clientName';\n";
26
print "\$configuration{'serialNumber'} = '$serialNumber';\n";
27
print "\$configuration{'hostname'} = '$hostname';\n";
28
print "\$configuration{'UUID'} = '$UUID';\n";
29
print "\$configuration{'moduleDirs'} = ( '" . join( "','", @moduleDirs) . "' );\n";
30
print "\$configuration{'scriptDirs'} = ( '" . join( "','", @scriptDirs) . "' );\n";
31
foreach my $level ( sort keys %$transports ) {
32
   foreach my $key ( sort keys %{ $$transports{$level} } ) {
33
      print "\$configuration{'transports'}{$level}{'$key'} = '$$transports{$level}{$key}';\n";
34
   }
35
}
36
1;
37
 
38
sub getSerial {
39
   my $serial = `sudo dmidecode -s system-serial-number`;
40
   chomp $serial;
41
   return $serial;
42
}
43
 
44
sub getUUID {
45
   my $UUID = `sudo dmidecode -s system-uuid`;
46
   chomp $UUID;
47
   return $UUID;
48
}
49