IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4897


Ignore:
Timestamp:
Aug 29, 2005, 2:04:04 PM (21 years ago)
Author:
jhoblitt
Message:

add script body and pod

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/bin/neb-initdb

    r4882 r4897  
    11#!/usr/bin/env perl
     2
     3# Copyright (C) 2005  Joshua Hoblitt
     4#
     5# $Id: neb-initdb,v 1.2 2005-08-30 00:04:04 jhoblitt Exp $
     6
     7use strict;
     8use warnings FATAL => qw( all );
     9
     10use vars qw( $VERSION );
     11$VERSION = '0.01';
     12
     13use DBI;
     14use Nebulous::Server::SQL;
     15
     16use Getopt::Long qw( GetOptions :config auto_help auto_version );
     17use Pod::Usage qw( pod2usage );
     18
     19my ($db, $dbuser, $dbpass);
     20GetOptions(
     21    'db=s'      => \$db,
     22    'user=s'    => \$dbuser,
     23    'pass=s'    => \$dbpass,
     24) || pod2usage( 2 );
     25
     26pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     27pod2usage( -msg => "Required options: --db --user --pass", -exitval => 2 )
     28    unless $db && $dbuser && $dbpass;
     29
     30my $dbh = DBI->connect(
     31    "DBI:mysql:database=$db:host=localhost",
     32    $dbuser,
     33    $dbpass,
     34    {
     35        RaiseError => 1,
     36        PrintError => 0,
     37        AutoCommit => 1,
     38    },
     39);
     40
     41my $sql = Nebulous::Server::SQL->new();
     42
     43print "Dropping any existing tables...";
     44
     45foreach my $statement (@{ $sql->get_db_clear }) {
     46    $dbh->do( $statement );
     47}
     48
     49print " OK\nCreating new tables...";
     50
     51foreach my $statement (@{ $sql->get_db_schema }) {
     52    $dbh->do( $statement );
     53}
     54
     55print " OK\n";
     56
     57__END__
     58
     59=pod
     60
     61=head1 NAME
     62
     63neb-initdb - initialize a Nebulous server database
     64
     65=head1 SYNOPSIS
     66
     67    neb-initdb --db <database> --user <username> --pass <password>
     68
     69=head1 DESCRIPTION
     70
     71This program initialize a database for use by L<Nebulous::Server> by creating
     72the appropriate set of tables.  Any pre-existing tables with conflicting names
     73are first removed.
     74
     75=head1 OPTIONS
     76
     77=over 4
     78
     79=item * --db|-d <database>
     80
     81Name of database (C<namespace>) to create tables in.
     82
     83=item * --user|-u <username>
     84
     85Username to authenticate with.
     86
     87=item * --pass|-p <password>
     88
     89Password to authenticate with.
     90
     91=back
     92
     93=head1 CREDITS
     94
     95Just me, myself, and I.
     96
     97=head1 SUPPORT
     98
     99Please contact the author directly via e-mail.
     100
     101=head1 AUTHOR
     102
     103Joshua Hoblitt <jhoblitt@cpan.org>
     104
     105=head1 COPYRIGHT
     106
     107Copyright (C) 2005  Joshua Hoblitt.  All rights reserved.
     108
     109This program is free software; you can redistribute it and/or modify it under
     110the terms of the GNU General Public License as published by the Free Software
     111Foundation; either version 2 of the License, or (at your option) any later
     112version.
     113
     114This program is distributed in the hope that it will be useful, but WITHOUT ANY
     115WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
     116PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     117
     118You should have received a copy of the GNU General Public License along with
     119this program; if not, write to the Free Software Foundation, Inc., 59 Temple
     120Place - Suite 330, Boston, MA  02111-1307, USA.
     121
     122The full text of the license can be found in the L<perlgpl> Pod as supplied
     123with Perl 5.8.1 and later.
     124
     125=head1 SEE ALSO
     126
     127L<Nebulous::Server>
     128
     129=cut
  • trunk/Nebulous/bin/neb-initdb

    r4882 r4897  
    11#!/usr/bin/env perl
     2
     3# Copyright (C) 2005  Joshua Hoblitt
     4#
     5# $Id: neb-initdb,v 1.2 2005-08-30 00:04:04 jhoblitt Exp $
     6
     7use strict;
     8use warnings FATAL => qw( all );
     9
     10use vars qw( $VERSION );
     11$VERSION = '0.01';
     12
     13use DBI;
     14use Nebulous::Server::SQL;
     15
     16use Getopt::Long qw( GetOptions :config auto_help auto_version );
     17use Pod::Usage qw( pod2usage );
     18
     19my ($db, $dbuser, $dbpass);
     20GetOptions(
     21    'db=s'      => \$db,
     22    'user=s'    => \$dbuser,
     23    'pass=s'    => \$dbpass,
     24) || pod2usage( 2 );
     25
     26pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     27pod2usage( -msg => "Required options: --db --user --pass", -exitval => 2 )
     28    unless $db && $dbuser && $dbpass;
     29
     30my $dbh = DBI->connect(
     31    "DBI:mysql:database=$db:host=localhost",
     32    $dbuser,
     33    $dbpass,
     34    {
     35        RaiseError => 1,
     36        PrintError => 0,
     37        AutoCommit => 1,
     38    },
     39);
     40
     41my $sql = Nebulous::Server::SQL->new();
     42
     43print "Dropping any existing tables...";
     44
     45foreach my $statement (@{ $sql->get_db_clear }) {
     46    $dbh->do( $statement );
     47}
     48
     49print " OK\nCreating new tables...";
     50
     51foreach my $statement (@{ $sql->get_db_schema }) {
     52    $dbh->do( $statement );
     53}
     54
     55print " OK\n";
     56
     57__END__
     58
     59=pod
     60
     61=head1 NAME
     62
     63neb-initdb - initialize a Nebulous server database
     64
     65=head1 SYNOPSIS
     66
     67    neb-initdb --db <database> --user <username> --pass <password>
     68
     69=head1 DESCRIPTION
     70
     71This program initialize a database for use by L<Nebulous::Server> by creating
     72the appropriate set of tables.  Any pre-existing tables with conflicting names
     73are first removed.
     74
     75=head1 OPTIONS
     76
     77=over 4
     78
     79=item * --db|-d <database>
     80
     81Name of database (C<namespace>) to create tables in.
     82
     83=item * --user|-u <username>
     84
     85Username to authenticate with.
     86
     87=item * --pass|-p <password>
     88
     89Password to authenticate with.
     90
     91=back
     92
     93=head1 CREDITS
     94
     95Just me, myself, and I.
     96
     97=head1 SUPPORT
     98
     99Please contact the author directly via e-mail.
     100
     101=head1 AUTHOR
     102
     103Joshua Hoblitt <jhoblitt@cpan.org>
     104
     105=head1 COPYRIGHT
     106
     107Copyright (C) 2005  Joshua Hoblitt.  All rights reserved.
     108
     109This program is free software; you can redistribute it and/or modify it under
     110the terms of the GNU General Public License as published by the Free Software
     111Foundation; either version 2 of the License, or (at your option) any later
     112version.
     113
     114This program is distributed in the hope that it will be useful, but WITHOUT ANY
     115WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
     116PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     117
     118You should have received a copy of the GNU General Public License along with
     119this program; if not, write to the Free Software Foundation, Inc., 59 Temple
     120Place - Suite 330, Boston, MA  02111-1307, USA.
     121
     122The full text of the license can be found in the L<perlgpl> Pod as supplied
     123with Perl 5.8.1 and later.
     124
     125=head1 SEE ALSO
     126
     127L<Nebulous::Server>
     128
     129=cut
Note: See TracChangeset for help on using the changeset viewer.