Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 26 Rev 28
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
package sysinfoconf;
3
package sysinfoconf;
4
 
4
 
5
our $VERSION = '1.0';
5
our $VERSION = '1.0.1';
6
use warnings;
6
use warnings;
7
use strict;  
7
use strict;  
8
 
8
 
9
use Exporter;
9
use Exporter;
10
 
10
 
11
our @ISA = qw( Exporter );
11
our @ISA = qw( Exporter );
12
our @EXPORT = qw( $clientName $serialNumber $hostname @moduleDirs @scriptDirs 
12
our @EXPORT = qw( $clientName $serialNumber $hostname @moduleDirs @scriptDirs 
13
                  $transports $sysinfo3 %sendTypes $binDir $modulesDir
13
                  $transports $sysinfo3 %sendTypes $binDir $modulesDir
14
                  $scriptsDir $confDir $binName $confName
14
                  $scriptsDir $confDir $binName $confName
15
                  &showConf &transportsToConfig &getAnswer &yesno  
15
                  &showConf &transportsToConfig &getAnswer &yesno  
16
                  &writeConfig &processParameters
16
                  &writeConfig &processParameters $TESTING
17
                );
17
                );
18
 
18
 
19
 
19
our $TESTING;
20
$clientName = '';
20
our $clientName = '';
21
$serialNumber = '';
21
our $serialNumber = '';
22
$hostname = '';
22
our $hostname = '';
23
@moduleDirs = ( '/opt/camp/sysinfo-client/modules', '/etc/camp/sysinfo-client/modules' );
23
our @moduleDirs = ( '/opt/camp/sysinfo-client/modules', '/etc/camp/sysinfo-client/modules' );
24
@scriptDirs = ( '/opt/camp/sysinfo-client/scripts', '/etc/camp/sysinfo-client/scripts' );
24
our @scriptDirs = ( '/opt/camp/sysinfo-client/scripts', '/etc/camp/sysinfo-client/scripts' );
25
$transports = {}; # holds transportation mechanisms
25
our $transports = {}; # holds transportation mechanisms
26
# the following are keys which are specific to the different transport channels
26
# the following are keys which are specific to the different transport channels
27
 
27
 
28
$sysinfo3 = '/etc/camp/sysinfo-client/sysinfo-client.conf';
28
our $sysinfo3 = '/etc/camp/sysinfo-client/sysinfo-client.conf';
29
 
29
 
30
$binDir = '/opt/camp/sysinfo-client';
30
our $binDir = '/opt/camp/sysinfo-client';
31
$modulesDir = $binDir . '/modules';
31
our $modulesDir = $binDir . '/modules';
32
$scriptsDir = $binDir . '/scripts';
32
our $scriptsDir = $binDir . '/scripts';
33
$confDir = '/etc/camp/sysinfo-client';
33
our $confDir = '/etc/camp/sysinfo-client';
34
 
34
 
35
$binName = 'sysinfo-client';
35
our $binName = 'sysinfo-client';
36
$confName = 'sysinfo-client.conf';
36
our $confName = 'sysinfo-client.conf';
37
 
37
 
38
 
38
 
39
%sendTypes = ( 
39
our %sendTypes = ( 
40
                  'SendEmail' =>    { 'sendScript' => 'sendEmailScript',
40
                  'SendEmail' =>    { 'sendScript' => 'sendEmailScript',
41
                                      'keys' => 
41
                                      'keys' => 
42
                                      [
42
                                      [
43
                                        'mailTo',
43
                                        'mailTo',
44
                                        'mailSubject',
44
                                        'mailSubject',
Line 105... Line 105...
105
   my $default = $answers[0];
105
   my $default = $answers[0];
106
   my $onlyOneAnswer = scalar( @answers ) == 1;
106
   my $onlyOneAnswer = scalar( @answers ) == 1;
107
   print $prompt . '[ ';
107
   print $prompt . '[ ';
108
   $answers[0] = uc $answers[0] unless $onlyOneAnswer;
108
   $answers[0] = uc $answers[0] unless $onlyOneAnswer;
109
   print join( ' | ', @answers ) . ' ]: ';
109
   print join( ' | ', @answers ) . ' ]: ';
110
   $thisAnswer = <>;
110
   my $thisAnswer = <>;
111
   chomp $thisAnswer;
111
   chomp $thisAnswer;
112
   $thisAnswer = $default unless $thisAnswer;
112
   $thisAnswer = $default unless $thisAnswer;
113
   return $thisAnswer;
113
   return $thisAnswer;
114
}
114
}
115
 
115