App-FTNDB
view release on metacpan or search on metacpan
bin/ftndb-admin view on Meta::CPAN
undef $opt_c;
}
else {
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\n";
# Get the definition of the log file
$log_file = $ftndb_config->{_}->{LogFile};
=item -x
Debug option.
=cut
if ($opt_x) {
logging($log_file, $log_id, 'Debug flag is set');
}
=item -v
Verbose option.
=cut
if ($opt_v) {
logging($log_file, $log_id, 'Verbose 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 -d
Name of the database being created or dropped.
=cut
if ($opt_d) {
$database_name = $opt_d;
undef $opt_d;
}
=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.
=back
=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
}
=head1 COMMANDS
=over
=item create database
This will create a database an SQL database server being used
for Fidonet/FTN processing. If it already exists, it will drop
it first, before going on to create it again.
=item drop database
This will drop a database if it exists in an SQL database server
being used for Fidonet/FTN processing.
=item create table
This will create a nodelist table in an SQL database being used
for Fidonet/FTN nodelist processing. If it already exists, it
will drop it first before going on to create it again.
bin/ftndb-admin view on Meta::CPAN
########################################################################
# Display Version message
########################################################################
sub VERSION_MESSAGE {
my $fh = shift;
print {$fh} "ftndb-admin 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 rquired 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 a database.
=item Password
Database password.
For an SQLite database, this defaults to an empty string as it is not
needed for that type of a database.
=back
This is an example of the contents of an ftndb.cfg file:
# ftndb.cfg
LogFile=/opt/ftndb/ftndb.log
[Database]
Type=mysql
Name=ftndbtst
User=sysop
Password=ftndbtst
=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-admin -c $CFGFILE -t Nodelist -v create table>
=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
as I make changes.
Note that you can also report any bugs or feature requests to
C<bug-ftndb at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-FTNDB>;
however, the FTN Database application Issue tracker at the
SourceForge project is preferred.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc ftndb-admin
You can also look for information at:
=over 4
=item * FTN Database application issue tracker
L<https://sourceforge.net/p/ftnpl/ftndb/tickets/>
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-FTNDB>
( run in 1.057 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )