Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 44 Rev 45
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
-
 
3
# v1.2.0 20161022 RWR
-
 
4
# moved makeConfig here so it is usable by install and configure
-
 
5
 
3
package sysinfoconf;
6
package sysinfoconf;
4
 
7
 
5
#
-
 
6
# Can't use an undefined value as an ARRAY reference at /home/rodolico/scripts/camp_sysinfo_client_3/sysinfoconf.pm line 105, <> line 9.
-
 
7
#
-
 
8
 
8
 
9
our $VERSION = '1.1.2';
9
our $VERSION = '1.2.0';
10
use warnings;
10
use warnings;
11
use strict;  
11
use strict;  
12
 
12
 
13
use Data::Dumper;
13
use Data::Dumper;
14
use File::Basename;
14
use File::Basename;
Line 19... Line 19...
19
our @EXPORT = qw( $clientName $serialNumber $hostname @moduleDirs @scriptDirs 
19
our @EXPORT = qw( $clientName $serialNumber $hostname @moduleDirs @scriptDirs 
20
                  $transports $sysinfo3 %sendTypes $binDir $moduleDir
20
                  $transports $sysinfo3 %sendTypes $binDir $moduleDir
21
                  $scriptDir $confDir $binName $confName
21
                  $scriptDir $confDir $binName $confName
22
                  &showConf &transportsToConfig &getAnswer &yesno  
22
                  &showConf &transportsToConfig &getAnswer &yesno  
23
                  &writeConfig &processParameters $TESTING &checkDirectoryExists
23
                  &writeConfig &processParameters $TESTING &checkDirectoryExists
24
                  &runCommand &setDryRun &enableModules
24
                  &runCommand &setDryRun &enableModules &makeConfig
25
                );
25
                );
26
 
26
 
27
our $TESTING = 0;
27
our $TESTING = 0;
28
our $dryRun;
28
our $dryRun;
29
our $clientName = '';
29
our $clientName = '';
Line 124... Line 124...
124
      } # foreach
124
      } # foreach
125
   } # foreach
125
   } # foreach
126
   return $config;
126
   return $config;
127
} # transportsToConfig
127
} # transportsToConfig
128
 
128
 
-
 
129
sub makeConfig {
-
 
130
   my @configFileNames = @_;
-
 
131
   my %config;
-
 
132
   my $clientName;
-
 
133
   my $serialNumber;
-
 
134
   my $hostname;
-
 
135
   my @moduleDirs;
-
 
136
   my @scriptDirs;
-
 
137
   my $transports = {};
-
 
138
 
-
 
139
   foreach my $config ( @configFileNames ) {
-
 
140
      open CONF,"<$config" or die "could not open $config: $!\n";
-
 
141
      my $contents = join( '', <CONF> );
-
 
142
      close CONF;
-
 
143
      # now, eval the information we just read.
-
 
144
      # NOTE: we must turn off strict while doing this, and we die if something breaks.
-
 
145
      no strict "vars"; eval( $contents ); use strict "vars"; die "Error during eval: $@\n" if $@;
-
 
146
   }
-
 
147
   unless ( $hostname ) {
-
 
148
      $hostname = `hostname -f`;
-
 
149
      chomp $hostname;
-
 
150
   }
-
 
151
 
-
 
152
 
-
 
153
   $config{'clientName'} = $clientName;
-
 
154
   $config{'serialNumber'} = $serialNumber;
-
 
155
   $config{'hostname'} = $hostname;
-
 
156
   $config{'moduleDirs'} = [ @moduleDirs ];
-
 
157
   $config{'scriptDirs'} = [ @scriptDirs ];
-
 
158
   $config{'transports'} = $transports;
-
 
159
   return \%config;
-
 
160
}
-
 
161
 
129
# prompt the user for a response, then allow them to enter it
162
# prompt the user for a response, then allow them to enter it
130
# the first response is considered the default and is printed
163
# the first response is considered the default and is printed
131
# in all caps if more than one exists
164
# in all caps if more than one exists
132
# first answer is used if they simply press the Enter
165
# first answer is used if they simply press the Enter
133
# key. The response is returned all lower case if more than one
166
# key. The response is returned all lower case if more than one