Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 28 Rev 45
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
use warnings;
3
use warnings;
4
use strict;
4
use strict;
5
 
5
 
-
 
6
# v1.1.0 20161022 RWR
-
 
7
# use library sysinfoconf.pm for loading, editing and displaying config
-
 
8
 
6
our $VERSION = '1.0.2';
9
our $VERSION = '1.1.0';
7
 
10
 
8
# find our location and use it for searching for libraries
11
# find our location and use it for searching for libraries
9
BEGIN {
12
BEGIN {
10
   use FindBin;
13
   use FindBin;
11
   use File::Spec;
14
   use File::Spec;
12
   use lib File::Spec->catdir($FindBin::Bin);
15
   use lib File::Spec->catdir($FindBin::Bin);
13
}
16
}
14
 
17
 
15
use sysinfoconf; # a library of shared routines with install.pl
18
use sysinfoconf; # a library of shared routines with install.pl
16
 
19
 
-
 
20
my $config;
17
 
21
 
18
sub findSendEmail {
22
sub findSendEmail {
19
   my $currentLocation = shift;
23
   my $currentLocation = shift;
20
   my @possibles = ( '/opt/sendEmail/sendEmail', '/opt/sendEmail/sendEmail.pl' );
24
   my @possibles = ( '/opt/sendEmail/sendEmail', '/opt/sendEmail/sendEmail.pl' );
21
   return $currentLocation if ( $currentLocation && -x $currentLocation );
25
   return $currentLocation if ( $currentLocation && -x $currentLocation );
Line 31... Line 35...
31
   }
35
   }
32
   return '';
36
   return '';
33
}
37
}
34
 
38
 
35
sub userConfirmation {
39
sub userConfirmation {
-
 
40
   my $config = shift;
36
   my $temp;
41
   my $temp;
37
   
42
   
38
   $clientName = &getAnswer( "Client Name ", ($clientName) );
43
   $$config{'clientName'} = &getAnswer( "Client Name ", ($$config{'clientName'}) );
39
   $serialNumber = &getAnswer( "Serial Number ", ($serialNumber) );
44
   $$config{'serialNumber'} = &getAnswer( "Serial Number ", ($$config{'serialNumber'}) );
40
   $hostname = &getAnswer( "Host Name ", ($hostname) );
45
   $$config{'hostname'} = &getAnswer( "Host Name ", ($$config{'hostname'}) );
41
 
46
 
42
   $temp = join( ',',@moduleDirs );
47
   $temp = join( ",", @{ $$config{ 'moduleDirs' } } );
43
   $temp = &getAnswer( "Locations to search for modules (comma separated) ", ($temp) );
48
   $temp = &getAnswer( "Locations to search for modules (comma separated) ", ($temp) );
44
   @moduleDirs = split( ',', $temp );
49
   $$config{ 'moduleDirs' } = [ split( ',', $temp ) ];
45
 
50
 
46
   $temp = join( ',',@scriptDirs );
51
   $temp = join( ",", @{ $$config{ 'scriptDirs' } } );
47
   $temp = &getAnswer( "Locations to search for scripts (comma separated) ", ($temp) );
52
   $temp = &getAnswer( "Locations to search for scripts (comma separated) ", ($temp) );
48
   @scriptDirs = split( ',', $temp );
53
   $$config{ 'scriptDirs' } = [ split( ',', $temp ) ];
49
 
54
 
50
}
55
}
51
 
56
 
52
sub setUpTransport {
57
sub setUpTransport {
53
   my ($priority, $transport, $fields, $type ) = @_;
58
   my ($priority, $transport, $fields, $type ) = @_;
Line 116... Line 121...
116
      print '='x40 . "\n";
121
      print '='x40 . "\n";
117
   }
122
   }
118
}
123
}
119
 
124
 
120
 
125
 
121
sub loadConfig {
-
 
122
   # See if existing configuration. If so, offer to load it
-
 
123
   if ( -f $sysinfo3 && &yesno( 'I found an existing configuration, modify it ' ) ) {
-
 
124
      print "Loading defaults from existing config $sysinfo3\n";
-
 
125
      my $client_name;
-
 
126
      open SEED, "<$sysinfo3" or die "Could not open $sysinfo3: $!\n";
-
 
127
      my $temp = join( '', <SEED> );
-
 
128
      close SEED;
-
 
129
      eval( $temp );
-
 
130
   }
-
 
131
}
-
 
132
 
-
 
133
&processParameters( @ARGV );
126
&processParameters( @ARGV );
134
 
127
 
135
&loadConfig();
128
if ( -f $sysinfo3 && &yesno( 'I found an existing configuration, modify it ' ) ) {
136
 
-
 
137
unless ( $hostname ) {
129
   print "Loading defaults from existing config $sysinfo3\n";
138
   $hostname = `hostname -f`;
130
   $config = makeConfig( ( $sysinfo3 )  );
139
   chomp $hostname;
131
   my $content = &showConf( $config );
140
}
132
}
141
 
133
 
142
&userConfirmation();
134
&userConfirmation( $config );
-
 
135
 
-
 
136
#use Data::Dumper;
-
 
137
#print Dumper( $config ); die;
-
 
138
 
143
&doTransports( $transports );
139
&doTransports( $$config{'transports'} );
144
 
140
 
145
print "The following is the configuration I'll write out\n" . '-'x40 . "\n";
141
print "The following is the configuration I'll write out\n" . '-'x40 . "\n";
146
print &showConf(  );
142
print &showConf( $config );
147
print '-'x40 . "\n";
143
print '-'x40 . "\n";
148
print &writeConfig( $confDir, $confName, &showConf() ) if &yesno( "Write this configuration" );
144
print &writeConfig( $confDir, $confName, &showConf() ) if &yesno( "Write this configuration" );
149
 
145
 
150
 
146
 
151
print "sysinfo-client has been installed configured. You can return to\nthis screen at any time by running /opt/camp/sysinfo/config.pl\n";
147
print "sysinfo-client has been installed configured. You can return to\nthis screen at any time by running /opt/camp/sysinfo/config.pl\n";