—#!perl
use
strict;
use
warnings;
use
Pod::Usage;
my
$version
=
$Shell::Var::Reader::CMDB::VERSION
;
my
$action
;
my
$version_flag
;
my
$help
;
my
$dir
;
my
$exists_okay
;
my
$verbose
;
my
$init_group_slug
;
GetOptions(
'd=s'
=> \
$dir
,
'eo=s'
=> \
$exists_okay
,
'verbose=s'
=> \
$verbose
,
'group=s'
=> \
$init_group_slug
,
'version'
=> \
$version_flag
,
'help'
=> \
$help
,
);
if
(
$version_flag
) {
'cmdb_shell_var_reader v. '
.
$version
.
"\n"
;
exit
255;
}
if
(
$help
) {
pod2usage(
-exitval
=> 255,
-verbose
=> 2,
-output
=> \
*STDOUT
);
}
if
( !
defined
(
$dir
) ) {
if
( -f
'./.shell_var_reader'
) {
$dir
=
'./'
;
}
elsif
( -f
'../.shell_var_reader'
) {
$dir
=
'../'
;
}
elsif
( -f
'../../.shell_var_reader'
) {
$dir
=
'../../'
;
}
elsif
( -f
'../../../.shell_var_reader'
) {
$dir
=
'../../../'
;
}
elsif
( -f
'../../../../.shell_var_reader'
) {
$dir
=
'../../../../'
;
}
}
## end if ( !defined($dir) )
Shell::Var::Reader::CMDB->update(
dir
=>
$dir
,
verbose
=>
$verbose
,
);
exit
0;
=head1 NAME
cmdb_shell_var_reader - Bulk run shell_var_reader for CMDB build purposes.
=head1 SYNOPSIS
=head1 FLAGS
=head2 --verbose <0/1>
A boolean value for if it should be verbose or not.
Default :: 1
=head2 -d <dir>
The directory to operate on. If undef, it will check the following
directories for the file '.shell_var_reader'.
./
../
../../
../../../
../../../../
=head1 LAYOUT & WORKFLOW
Specifically named files.
- .shell_var_reader :: Marks the base directory as being for a shell_var_reader CMDB.
Specifically named directories.
- cmdb :: The CMDB directory.
- json_confs :: Generated JSON confs.
- shell_confs :: Generated shell confs.
- toml_confs :: Generated TOML confs.
- yaml_confs :: Generated YAML confs.
Other directories that that don't start with a '.' or contiain a file named '.not_a_system_group'
will be processed as system groups.
These directories will be searched for files directly below them for files ending in '.sh' and not
starting with either a '_' or a '.'. The name used for a system is the name of the file minus the
ending '.sh', so 'foo.bar.sh' would generate a config for a system named 'foo.bar'.
When it finds a file to use as a system config, it will point shell_var_reader at it with CMDB
enabled and with the name of that system set the hostname to use with the CMDB. That name will
also be saved as the variable 'SYSTEM_NAME', provided that variable is not defined already. If
a 'munger.pl' exists, that file is used as the munger file. shell_var_reader will be ran four
times, once to generate each config type.
=cut