Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 204 Rev 211
Line 188... Line 188...
188
      print "Can not automatically do this at this time\nManually edit the file (press enter to continue)";
188
      print "Can not automatically do this at this time\nManually edit the file (press enter to continue)";
189
      my $t = <>;
189
      my $t = <>;
190
   }
190
   }
191
}
191
}
192
 
192
 
-
 
193
sub testConfig {
-
 
194
   my $config = shift;
-
 
195
   my @return;
-
 
196
   push @return, 'No client name given' unless $config->{'clientName'};
-
 
197
   push @return, 'No host name given' unless $config->{'hostname'};
-
 
198
   push @return, 'No serial number given' unless $config->{'serialNumber'};
-
 
199
   push @return, 'No UUID given' unless $config->{'UUID'};
-
 
200
   push @return, 'No Module Directories given' unless $config->{'moduleDirs'};
-
 
201
   push @return, 'No Script Directories given' unless $config->{'scriptDirs'};
-
 
202
   
-
 
203
   return @return ? join ( "\n", @return ) . "\n" : 'Ok';
-
 
204
}
-
 
205
 
193
sub help {
206
sub help {
194
   print "$0 version $VERSION\n";
207
   print "$0 version $VERSION\n";
195
   print "Reads one or more sysinfo configuration file and\nallows user to edit the values\n\n";
208
   print "Reads one or more sysinfo configuration file and\nallows user to edit the values\n\n";
196
   print "$0 --verbose --file=/full/paht/to/input -output=/full/path/to/sysinfo-client.yaml\n";
209
   print "$0 --verbose --file=/full/paht/to/input -output=/full/path/to/sysinfo-client.yaml\n";
197
   print "   --verbose may be entered more than one time to increase verbosity\n";
210
   print "   --verbose may be entered more than one time to increase verbosity\n";
Line 210... Line 223...
210
my @confFileName;
223
my @confFileName;
211
my $outputFile;
224
my $outputFile;
212
my $verbose;
225
my $verbose;
213
my $help;
226
my $help;
214
my $version;
227
my $version;
-
 
228
my $test = 0;
-
 
229
my $dryRun = 0;
-
 
230
my $quiet = 0;
215
 
231
 
216
# handle any command line parameters that may have been passed in
232
# handle any command line parameters that may have been passed in
217
# verbose is incremental, so for example, -vv would give more info than -v
233
# verbose is incremental, so for example, -vv would give more info than -v
218
# there can be multiple files passed, and an entry can have a comma
234
# there can be multiple files passed, and an entry can have a comma
219
# separated list. The files will be processed in order, with the last
235
# separated list. The files will be processed in order, with the last
220
# one passed in being the one that overrides everything.
236
# one passed in being the one that overrides everything.
221
GetOptions (
237
GetOptions (
222
            "verbose|v+"  => \$verbose, # verbosity level, 0-9
238
            "verbose|v+"  => \$verbose, # verbosity level, 0-9
223
            'file|f=s'    => \@confFileName, # array of files to read
239
            'file|f=s'    => \@confFileName, # array of files to read
224
            'output|o=s'  => \$outputFile, # file to save to
240
            'output|o=s'  => \$outputFile, # file to save to
-
 
241
            'test|t'      => \$test, # test the config file
-
 
242
            'dryrun|n'    => \$dryRun, # do not save result
-
 
243
            'quiet|q'     => \$quiet, # do not ask any questions
225
            'help|h'      => \$help
244
            'help|h'      => \$help
226
            ) or die "Error parsing command line\n";
245
            ) or die "Error parsing command line\n";
227
                  
246
                  
228
if ( $help ) { &help() ; exit; }
247
if ( $help ) { &help() ; exit; }
229
 
248
 
230
# if they passed something like -f file1,file2,file3, parse it out
249
# if they passed something like -f file1,file2,file3, parse it out
231
@confFileName = split(/,/,join(',',@confFileName));
250
@confFileName = split(/,/,join(',',@confFileName));
232
 
251
 
233
# look for the standard configuration file in the standard place
252
# look for the standard configuration file in the standard place
234
( $confDir, $sysinfo3 ) = &findConf( $sysinfo3 );
253
( $confDir, $sysinfo3 ) = &findConf( $sysinfo3 );
235
# add it at the tail end of the list
254
$outputFile = $confDir . '/' . $sysinfo3 unless $outputFile;
236
push @confFileName, $confDir . "/" . $sysinfo3 if ( $confDir );
255
push @confFileName, $confDir . "/" . $sysinfo3 if ( $confDir );
237
$outputFile = $confFileName[-1] unless $outputFile;
-
 
238
 
256
 
239
print "Loading defaults from existing configs\n";
257
print "Loading defaults from existing configs\n";
240
$config = &makeConfig( @confFileName  );
258
$config = &makeConfig( $outputFile, @confFileName  );
241
 
259
 
242
my $selection;
260
my $selection;
243
while ( ( $selection = &displayEditScreen( $config ) ) ne 'd' ) {
261
while ( ! $quiet && ( $selection = &displayEditScreen( $config ) ) ne 'd' ) {
244
   &editSelection( $selection );
262
   &editSelection( $selection );
245
}
263
}
246
 
264
 
-
 
265
my $testResults = &testConfig($config);
-
 
266
print "Error found in configuration file, manually run\n$0\n" if ( $testResults ne 'Ok' );
-
 
267
print $testResults if $test || $testResults ne 'Ok';
-
 
268
 
247
if ( &yesno( "Ready to write configuration to $outputFile, ok?" ) ) {
269
if ( $quiet || &yesno( "Ready to write configuration to $outputFile, ok?" ) ) {
-
 
270
   print "Config File written to $outputFile\n";
248
   &writeConfig( $outputFile, &showConf( $config ) );
271
   &writeConfig( $outputFile, &showConf( $config ) ) unless $dryRun;
249
}
272
}
250
 
273
 
251
#use Data::Dumper;
274
#use Data::Dumper;
252
#print Dumper( $config ); die;
275
#print Dumper( $config ); die;
253
 
276