#! /usr/bin/perl -w use strict ; use Repocafe ; my $prog = substr($0,rindex($0,'/')+1) ; my $Usage = < option V : show repocafe version ; exit ---------------------------------------- - test the repocafe config - test the database connection ---------------------------------------- USAGE sub Usage { die "$_[0]$Usage" ; } sub Error { die "$prog: $_[0]\n" ; } sub Warn { warn "$prog: $_[0]\n" ; } # usage: &GetOptions(ARG,ARG,..) defines $opt_ID as 1 or user spec'ed value # usage: &GetOptions(\%opt,ARG,ARG,..) defines $opt{ID} as 1 or user value # ARG = 'ID' | 'ID=SPC' | 'ID:SPC' for no-arg, required-arg or optional-arg # ID = perl identifier # SPC = i|f|s for integer, fixedpoint real or string argument use Getopt::Long ; Getopt::Long::config('no_ignore_case') ; our %opt = () ; Usage('') unless GetOptions ( \%opt, qw(V v q d u o c=s help) ) ; Usage("Arg count\n") unless @ARGV == 0 ; if ( $opt{help} ) { print $Usage ; exit 0 ; } if ( $opt{V} ) { printf "%s\n", Base::version ; exit ; } Repocafe::set_opt ( %opt ) ; my $Cafe = Repocafe -> new ( $opt{c}, 'do not connect' ) ; my $conf = $Cafe -> conf ; print "$prog : no config errors detected\n" ; sub try_connect { my $ownr = shift ; my $pswd = shift ; $Cafe -> db_connect_as ( $ownr, $pswd ) ; if ( $Cafe -> db -> dbh ) { print "$prog: connected as database user '$ownr'\n" ; $Cafe -> db -> dbh -> disconnect () ; } } if ( $opt{u} ) { print "$prog: database user 'db_user' empty or not configured\n" unless $conf -> db_user ; try_connect $conf -> db_user, $conf -> db_pswd ; } if ( $opt{o} ) { print "$prog: database user 'db_owner' empty or not configured\n" unless $conf -> db_owner ; try_connect $conf -> db_owner, $conf -> db_opswd ; }