IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17748


Ignore:
Timestamp:
May 19, 2008, 2:51:31 PM (18 years ago)
Author:
Paul Price
Message:

Allow dbname to be specified on the command line.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStoreServer/scripts/dsreg

    r16879 r17748  
    99use Getopt::Long qw( GetOptions );
    1010use Pod::Usage qw( pod2usage );
    11 use Digest::MD5::File qw( file_md5_hex ); 
     11use Digest::MD5::File qw( file_md5_hex );
    1212use DBI;
    1313use PS::IPP::Metadata::Config;
     
    1717
    1818use PS::IPP::Config qw($PS_EXIT_SUCCESS
    19                        $PS_EXIT_UNKNOWN_ERROR
    20                        $PS_EXIT_SYS_ERROR
    21                        $PS_EXIT_CONFIG_ERROR
    22                        $PS_EXIT_PROG_ERROR
    23                        $PS_EXIT_DATA_ERROR
    24                        $PS_EXIT_TIMEOUT_ERROR
    25                        metadataLookupStr
    26                        metadataLookupBool
    27                        caturi
    28                        );
     19                       $PS_EXIT_UNKNOWN_ERROR
     20                       $PS_EXIT_SYS_ERROR
     21                       $PS_EXIT_CONFIG_ERROR
     22                       $PS_EXIT_PROG_ERROR
     23                       $PS_EXIT_DATA_ERROR
     24                       $PS_EXIT_TIMEOUT_ERROR
     25                       metadataLookupStr
     26                       metadataLookupBool
     27                       caturi
     28                       );
    2929my $product;
    3030my $fileset;
     
    4343my $copyfiles;      # if set, copy files from this directory to the Data Store fileset
    4444my $datapath;       # source for files required if $linkfiles or $copyfiles
     45my $dbname;                     # Database name
    4546
    4647my $ds_dir;
     
    6263        'add'           =>      \$add,
    6364        'del'           =>      \$del,
    64         'product=s'     =>      \$product,
    65         'fileset=s'     =>      \$fileset,
    66         'type=s'        =>      \$fstype,
     65        'product=s'     =>      \$product,
     66        'fileset=s'     =>      \$fileset,
     67        'type=s'        =>      \$fstype,
    6768        'datapath=s'    =>      \$datapath,
    6869        'link'          =>      \$linkfiles,
    6970        'copy'          =>      \$copyfiles,
    7071        'rm'            =>      \$remove,
    71         'ps0=s'         =>      \$ps0,          # product specific columns 0 - 7
    72         'ps1=s'         =>      \$ps1,
    73         'ps2=s'         =>      \$ps2,
    74         'ps3=s'         =>      \$ps3,
    75         'ps4=s'         =>      \$ps4,
    76         'ps5=s'         =>      \$ps5,
    77         'ps6=s'         =>      \$ps6,
    78         'ps7=s'         =>      \$ps7
     72        'ps0=s'         =>      \$ps0,          # product specific columns 0 - 7
     73        'ps1=s'         =>      \$ps1,
     74        'ps2=s'         =>      \$ps2,
     75        'ps3=s'         =>      \$ps3,
     76        'ps4=s'         =>      \$ps4,
     77        'ps5=s'         =>      \$ps5,
     78        'ps6=s'         =>      \$ps6,
     79        'ps7=s'         =>      \$ps7
     80           'dbname'     =>      \$dbname,
    7981) or pod2usage(2);
    8082
     
    127129
    128130my $dbserver = metadataLookupStr($siteConfig, 'DBSERVER');
    129 my $dbname   = metadataLookupStr($siteConfig, 'DBNAME');
     131$dbname      = metadataLookupStr($siteConfig, 'DBNAME') unless defined $dbname;
    130132my $dbuser   = metadataLookupStr($siteConfig, 'DBUSER');
    131133my $dbpass   = metadataLookupStr($siteConfig, 'DBPASSWORD');
     
    232234    while (<STDIN>) {
    233235        $lineno++;
    234        
     236
    235237        my $filename;
    236238        my $filetype;
     
    246248        $filetype = shift @fields;
    247249
    248         # 
     250        #
    249251        # save any type specific fields provided in the string to be added to the
    250252        # VALUES list for this file
     
    265267                ."($path does not exist.\n");
    266268        }
    267        
     269
    268270        # Get MD5 sum
    269271        my $md5 = file_md5_hex($path);
    270272
    271         my $hashref = { 
     273        my $hashref = {
    272274            'file'      => $filename,
    273275            'bytes'     => $finfo[7],
     
    283285        die("empty filelist");
    284286    }
    285    
     287
    286288    #
    287289    # Prepare the fileset directory
     
    316318                die("failed to remove $fileset_dir");
    317319            }
    318            
     320
    319321            exit $PS_EXIT_UNKNOWN_ERROR;
    320322        }
     
    401403
    402404    pod2usage(
    403         -msg => 
     405        -msg =>
    404406"usage: $tmp[$#tmp] [--add|--del] --product prod_name --fileset fs_name --type fs_type [options]
    405407
     
    422424    --ps0 - ps7 Optional product specific data
    423425    --rm        with --del remove the fileset directory from the Data Store
    424    
     426
    425427$str",
    426428        -exitval => 2
Note: See TracChangeset for help on using the changeset viewer.