App-FTNDB
view release on metacpan or search on metacpan
bin/ftndb-nodelist view on Meta::CPAN
my $config_dir = File::Spec->curdir();
$config_file = File::Spec->join($config_dir, 'ftndb.cfg');
}
# Get configuration from file
my $ftndb_config = Config::Tiny->new();
$ftndb_config = Config::Tiny->read($config_file)
or die "Could not open configuration file: $config_file";
# Get the definition of the log file
$log_file = $ftndb_config->{_}->{LogFile};
my $log_id = 'nl2db';
logging($log_file, $log_id, "Starting ftndb-nodelist $VERSION ... ");
=item -v
Verbose option.
=cut
if ($opt_v) {
logging($log_file, $log_id, 'Verbose flag is set');
}
=item -x
Debug option.
=cut
if ($opt_x) {
logging($log_file, $log_id, 'Debug flag is set');
}
my %db_option = ();
# Get the definition of the database type
$db_option{'Type'} = $ftndb_config->{Database}->{Type};
if ($opt_v) { logging($log_file, $log_id, "Database type being used is $db_option{'Type'}") };
# Get the definition of the database name
$db_option{'Name'} = $ftndb_config->{Database}->{Name};
if ($opt_v) { logging($log_file, $log_id, "Database name being used is $db_option{'Name'}") };
# Get the definition of the database user
if ($db_option{'Type'} eq 'SQLite') {
$db_option{'User'} = q{};
} else {
$db_option{'User'} = $ftndb_config->{Database}->{User};
if ($opt_v) { logging($log_file, $log_id, "Database user being used is $db_option{'User'}") };
}
# Get the definition of the database password
if ($db_option{'Type'} eq 'SQLite') {
$db_option{'Password'} = q{};
} else {
$db_option{'Password'} = $ftndb_config->{Database}->{Password};
if ($opt_v) { logging($log_file, $log_id, "Database password being used is $db_option{'Password'}") };
}
=item -f
The nodelist file.
If the -e option is also set, then this is an exact file name. If -e is
not set, then this is the basename of the nodelist files. If -f is not
set, then when needed it defaults to "nodelist".
=item -e
If set, then the -f option must be exact file name. If not set, then
the -f option is the basename of a nodelist file.
=item -t
The nodelist table name to be used.
Note that if there is a period in the name, that period will be changed
to an underscore.
=cut
if ($opt_t) {
if ( $opt_t =~ /\./ ) { # period in proposed table name?
logging($log_file, $log_id, 'sqlite does not allow periods in table names.');
$opt_t =~ tr/\./_/; # change period to underscore
$table_name = $opt_t; #
logging($log_file, $log_id, "Changed table name to $table_name.");
}
else { # no period in name
$table_name = $opt_t; # just assign to variable
}
}
else {
$table_name = 'Nodelist'; # default table name
}
=item -n
If set, it is the FTN Net number being operated on.
=cut
if ($opt_n) {
$net_number = $opt_n;
logging($log_file, $log_id, "Defined Net: $net_number");
undef $opt_n;
}
=item -z
If defined; is the only zone being operated on.
=cut
if ($opt_z) {
bin/ftndb-nodelist view on Meta::CPAN
#########################################################################
# Display Version message
#########################################################################
sub VERSION_MESSAGE {
my $fh = shift;
print {$fh} "ftndb-nodelist version $VERSION\n";
return();
}
################################################################################
=head1 CONFIGURATION
Configuration information not provided by the command line options are
obtained from a configuration file. That can be defined by setting the
"-c" option, which is the path and file name of the configuration file
to be used. If that is not defined, it looks for a file named ftndb.cfg
in the current directory. The file contains configuration items listed
outside of a named section as well as those listed within a named section,
and blank lines and lines starting with a "#" are ignored.
The first items in the file are those outside of a named section:
=over 4
=item LogFile
This is the required filename and path of a log file.
=back
The B<Database> section in the configuration file has the following
keywords:
=over 4
=item Type
Database type.
This needs to be a database type for which a DBD module exists, the type
being the name as used in the DBD module. The default type is SQLite.
=item Name
Database name.
For an SQLite database; this needs to be at least the filename and can
also include a path.
=item User
Database user.
For an SQLite database, this defaults to an empty string as it is not
needed for that type of database.
=item Password
Database password.
For an SQLite database, this defaults to an empty string as it is not
needed for that type of database.
=back
The B<Nodelist> section in the configuration file has the following
keywords:
=over 4
=item Directory
The directory where the FTN Nodelist files are located.
=back
This is an example of the contents of an ftndb.cfg file for use with
FTN Nodelist related processing:
# ftndb.cfg
LogFile=/opt/ftndb/ftndb.log
[Database]
Type=mysql
Name=ftndbtst
User=sysop
Password=ftndbtst
[Nodelist]
Directory=/var/lib/ftn/nodelist
=head1 EXAMPLES
Given that $CFGFILE is a configuration file, the following command line can be
used to create an FTN Nodelist table in that database file:
C<ftndb-nodelist -c $CFGFILE -t Nodelist -v create table>
Given that NODELIST is the base nodelist filename and that $CFGFILE is an
existing configuration file, the following command line can be used to
load an FTN nodelist from a set of nodelist files all with the same
basename of NODELIST:
C<ftndb-nodelist -c $CFGFILE -f NODELIST -d fidonet -v load>
Given that $CFGFILE is an existing configuration file, the
following command line can be used to load a specified zone of the
specified domain from a specified nodelist:
C<ftndb-nodelist -c $CFGFILE -f nodelist.197 -d fidonet -z 1 -e -v load>
=head1 AUTHOR
Robert James Clay, C<< <jame at rocasa.us> >>
=head1 BUGS
Please report any bugs or feature requests via the web interface at
L<https://sourceforge.net/p/ftnpl/ftndb/tickets/>. I will be notified,
and then you'll automatically be notified of progress on your bug
( run in 1.736 second using v1.01-cache-2.11-cpan-5a3173703d6 )