| Line 52... |
Line 52... |
| 52 |
return '';
|
52 |
return '';
|
| 53 |
}
|
53 |
}
|
| 54 |
|
54 |
|
| 55 |
sub userConfirmation {
|
55 |
sub userConfirmation {
|
| 56 |
my $config = shift;
|
56 |
my $config = shift;
|
| 57 |
my $temp;
|
- |
|
| 58 |
|
57 |
|
| 59 |
$$config{'clientName'} = &getAnswer( "Client Name ", ($$config{'clientName'}) );
|
- |
|
| 60 |
$$config{'serialNumber'} = &getAnswer( "Serial Number ", ($$config{'serialNumber'}) );
|
- |
|
| 61 |
$$config{'UUID'} = &getAnswer( "UUID ", ($$config{'UUID'}) );
|
- |
|
| 62 |
$$config{'hostname'} = &getAnswer( "Host Name ", ($$config{'hostname'}) );
|
- |
|
| 63 |
|
- |
|
| 64 |
$temp = join( ",", @{ $$config{ 'moduleDirs' } } ) if $config->{ 'moduleDirs' };
|
- |
|
| 65 |
$temp = &getAnswer( "Locations to search for modules (comma separated) ", ($temp) );
|
- |
|
| 66 |
$$config{ 'moduleDirs' } = [ split( ',', $temp ) ];
|
- |
|
| 67 |
|
- |
|
| 68 |
$temp = join( ",", @{ $$config{ 'scriptDirs' } } ) if $config->{'scriptDirs'};
|
- |
|
| 69 |
$temp = &getAnswer( "Locations to search for scripts (comma separated) ", ($temp) );
|
- |
|
| 70 |
$$config{ 'scriptDirs' } = [ split( ',', $temp ) ];
|
- |
|
| 71 |
|
- |
|
| 72 |
}
|
58 |
}
|
| 73 |
|
59 |
|
| 74 |
sub setUpTransport {
|
60 |
sub setUpTransport {
|
| 75 |
my ($priority, $transport, $fields, $type ) = @_;
|
61 |
my ($priority, $transport, $fields, $type ) = @_;
|
| 76 |
$priority = getAnswer( 'Priority', $priority );
|
62 |
$priority = getAnswer( 'Priority', $priority );
|
| Line 198... |
Line 184... |
| 198 |
print "Can not automatically do this at this time\nManually edit the file (press enter to continue)";
|
184 |
print "Can not automatically do this at this time\nManually edit the file (press enter to continue)";
|
| 199 |
my $t = <>;
|
185 |
my $t = <>;
|
| 200 |
}
|
186 |
}
|
| 201 |
}
|
187 |
}
|
| 202 |
|
188 |
|
| - |
|
189 |
sub help {
|
| - |
|
190 |
print "$0 version $VERSION\n";
|
| - |
|
191 |
print "Reads one or more sysinfo configuration file and\nallows user to edit the values\n\n";
|
| - |
|
192 |
print "$0 --verbose --file=/full/paht/to/input -output=/full/path/to/sysinfo-client.yaml\n";
|
| - |
|
193 |
print " --verbose may be entered more than one time to increase verbosity\n";
|
| - |
|
194 |
print " --file may be entered multiple times and may contain a comma delimited group of files\n";
|
| - |
|
195 |
print " --output is the file which will be written to\n\n";
|
| - |
|
196 |
print "All parameters are optional\n";
|
| - |
|
197 |
print "Will search common locations for sysinfo-client.yaml and, if found, append this to the end\n";
|
| - |
|
198 |
print "of the input file list.\n";
|
| - |
|
199 |
print "If no --output is passed, will write to the last --file passed or the file which was found\n";
|
| - |
|
200 |
print "in the search\n";
|
| - |
|
201 |
print "All parameters accept the short flag, ie -v, -f, -o and -h\n";
|
| - |
|
202 |
exit;
|
| - |
|
203 |
}
|
| - |
|
204 |
|
| - |
|
205 |
|
| 203 |
my @confFileName;
|
206 |
my @confFileName;
|
| - |
|
207 |
my $outputFile;
|
| 204 |
my $verbose;
|
208 |
my $verbose;
|
| 205 |
my $help;
|
209 |
my $help;
|
| 206 |
my $version;
|
210 |
my $version;
|
| 207 |
|
211 |
|
| 208 |
# handle any command line parameters that may have been passed in
|
212 |
# handle any command line parameters that may have been passed in
|
| 209 |
# verbose is incremental, so for example, -vv would give more info than -v
|
213 |
# verbose is incremental, so for example, -vv would give more info than -v
|
| 210 |
# there can be multiple files passed, and an entry can have a comma
|
214 |
# there can be multiple files passed, and an entry can have a comma
|
| 211 |
# separated list. The files will be processed in order, with the last
|
215 |
# separated list. The files will be processed in order, with the last
|
| 212 |
# one passed in being the one that overrides everything.
|
216 |
# one passed in being the one that overrides everything.
|
| 213 |
GetOptions (
|
217 |
GetOptions (
|
| 214 |
"verbose|v+" => \$verbose, # verbosity level, 0-9
|
218 |
"verbose|v+" => \$verbose, # verbosity level, 0-9
|
| 215 |
'file|f=s' => \@confFileName,
|
219 |
'file|f=s' => \@confFileName, # array of files to read
|
| - |
|
220 |
'output|o=s' => \$outputFile, # file to save to
|
| 216 |
'help|h' => \$help
|
221 |
'help|h' => \$help
|
| 217 |
) or die "Error parsing command line\n";
|
222 |
) or die "Error parsing command line\n";
|
| 218 |
|
223 |
|
| 219 |
if ( $help ) { &help() ; exit; }
|
224 |
if ( $help ) { &help() ; exit; }
|
| 220 |
if ( $version ) { print "$0 version $VERSION\n"; exit; }
|
- |
|
| 221 |
|
225 |
|
| 222 |
# if they passed something like -f file1,file2,file3, parse it out
|
226 |
# if they passed something like -f file1,file2,file3, parse it out
|
| 223 |
@confFileName = split(/,/,join(',',@confFileName));
|
227 |
@confFileName = split(/,/,join(',',@confFileName));
|
| 224 |
|
228 |
|
| 225 |
# look for the standard configuration file in the standard place
|
229 |
# look for the standard configuration file in the standard place
|
| 226 |
( $confDir, $sysinfo3 ) = &findConf( $sysinfo3 );
|
230 |
( $confDir, $sysinfo3 ) = &findConf( $sysinfo3 );
|
| 227 |
# add it at the tail end of the list
|
231 |
# add it at the tail end of the list
|
| 228 |
push @confFileName, $confDir . "/" . $sysinfo3 if ( $confDir );
|
232 |
push @confFileName, $confDir . "/" . $sysinfo3 if ( $confDir );
|
| - |
|
233 |
$outputFile = $confFileName[-1] unless $outputFile;
|
| 229 |
|
234 |
|
| 230 |
print "Loading defaults from existing configs\n";
|
235 |
print "Loading defaults from existing configs\n";
|
| 231 |
$config = &makeConfig( @confFileName );
|
236 |
$config = &makeConfig( @confFileName );
|
| 232 |
|
237 |
|
| 233 |
my $selection;
|
238 |
my $selection;
|
| 234 |
while ( ( $selection = &displayEditScreen( $config ) ) ne 'd' ) {
|
239 |
while ( ( $selection = &displayEditScreen( $config ) ) ne 'd' ) {
|
| 235 |
&editSelection( $selection );
|
240 |
&editSelection( $selection );
|
| 236 |
}
|
241 |
}
|
| 237 |
|
242 |
|
| 238 |
die;
|
- |
|
| - |
|
243 |
if ( &yesno( "Ready to write configuration to $outputFile, ok?" ) ) {
|
| 239 |
#&userConfirmation( $config );
|
244 |
&writeConfig( $outputFile, &showConf( $config ) );
|
| - |
|
245 |
}
|
| 240 |
|
246 |
|
| 241 |
#use Data::Dumper;
|
247 |
#use Data::Dumper;
|
| 242 |
#print Dumper( $config ); die;
|
248 |
#print Dumper( $config ); die;
|
| 243 |
|
249 |
|
| 244 |
&doTransports( $$config{'transports'} );
|
250 |
#&doTransports( $$config{'transports'} );
|
| 245 |
|
- |
|
| 246 |
print "The following is the configuration I'll write out\n" . '-'x40 . "\n";
|
- |
|
| 247 |
print &showConf( $config );
|
- |
|
| 248 |
print '-'x40 . "\n";
|
- |
|
| 249 |
$confName = $confDir . '/' . $confName;
|
- |
|
| 250 |
print &writeConfig( $confName, &showConf( $config ) ) if &yesno( "Write this configuration to $confName" );
|
- |
|
| 251 |
|
- |
|
| 252 |
|
251 |
|
| 253 |
print "sysinfo-client has been installed configured. You can return to\nthis screen at any time by running config.pl\n";
|
- |
|
| 254 |
|
252 |
|
| 255 |
1;
|
253 |
1;
|