Subversion Repositories camp_sysinfo_client_3

Rev

Rev 68 | Rev 78 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68 Rev 77
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
# v1.2.0 20161022 RWR
3
# v1.2.0 20161022 RWR
4
# moved makeConfig here so it is usable by install and configure
4
# moved makeConfig here so it is usable by install and configure
-
 
5
#
-
 
6
# v1.3.0 20190108 RWR
-
 
7
# added UUID and set defaults for config file
5
 
8
 
6
package sysinfoconf;
9
package sysinfoconf;
7
 
10
 
8
 
11
 
9
our $VERSION = '1.2.0';
12
our $VERSION = '1.2.0';
Line 132... Line 135...
132
} # transportsToConfig
135
} # transportsToConfig
133
 
136
 
134
sub makeConfig {
137
sub makeConfig {
135
   my @configFileNames = @_;
138
   my @configFileNames = @_;
136
   my %config;
139
   my %config;
137
   my $clientName;
140
   my $clientName = '';
138
   my $serialNumber;
141
   my $serialNumber = '';
139
   my $hostname;
142
   my $hostname = '';
140
   my @moduleDirs;
143
   my @moduleDirs = '';
141
   my @scriptDirs;
144
   my @scriptDirs = '';
-
 
145
   my $UUID = '';
142
   my $transports = {};
146
   my $transports = {};
143
 
147
 
144
   foreach my $config ( @configFileNames ) {
148
   foreach my $config ( @configFileNames ) {
145
      open CONF,"<$config" or die "could not open $config: $!\n";
149
      open CONF,"<$config" or die "could not open $config: $!\n";
146
      my $contents = join( '', <CONF> );
150
      my $contents = join( '', <CONF> );
Line 156... Line 160...
156
   unless ( $serialNumber ) {
160
   unless ( $serialNumber ) {
157
      $serialNumber = `dmidecode -t 1 | grep 'Serial Number' | cut -d':' -f2` if `which dmidecode`;
161
      $serialNumber = `dmidecode -t 1 | grep 'Serial Number' | cut -d':' -f2` if `which dmidecode`;
158
      chomp $serialNumber;
162
      chomp $serialNumber;
159
      $serialNumber =~ s/\s//gi;
163
      $serialNumber =~ s/\s//gi;
160
   }
164
   }
-
 
165
   unless ( $UUID ) {
-
 
166
      $UUID = `dmidecode -t 1 | grep -i uuid | cut -d':' -f2` if `which dmidecode`;
-
 
167
      $UUID =~ s/\s//gi;
161
 
168
   }
162
 
169
 
163
   $config{'clientName'} = $clientName;
170
   $config{'clientName'} = $clientName;
164
   $config{'serialNumber'} = $serialNumber;
171
   $config{'serialNumber'} = $serialNumber;
-
 
172
   $config{'UUID'} = $UUID;
165
   $config{'hostname'} = $hostname;
173
   $config{'hostname'} = $hostname;
166
   $config{'moduleDirs'} = [ @moduleDirs ];
174
   $config{'moduleDirs'} = [ @moduleDirs ];
167
   $config{'scriptDirs'} = [ @scriptDirs ];
175
   $config{'scriptDirs'} = [ @scriptDirs ];
168
   $config{'transports'} = $transports;
176
   $config{'transports'} = $transports;
169
   return \%config;
177
   return \%config;