[OpenSIPS-Users] Possible problem in osipsconsole

Iulia Bublea iulia at opensips.org
Mon Aug 24 13:54:03 CEST 2009


Hi,

I rewrote the subroutine so that it will work:

sub validate_datadir ($type){
  if( -d $DATA_DIR."/$type" ) {
    $DB_SCHEMA = $DATA_DIR."/$type";
    return $DB_SCHEMA;	
  } else {
    print "Warn fallback to local workdir ./$type"\n";
    $DB_SCHEMA = "./$type";
    return $DB_SCHEMA;
 }	 
}

there is a modified version of the script on svn.


Regards,
Iulia

5evra wrote:
> In each create db function this if - else is exist:
>
>         if ( -d $DATA_DIR."/mysql" ) {
>                 $DB_SCHEMA=$DATA_DIR."/postgres";
>         } else {
>                 $DB_SCHEMA="./postgres";
>         }
>
> If you DONT install 'mysql' or this directory for a reason is not in
> $DATA_DIR, DB_SCHEMA will fallback to current workdir without notice, which
> is bad. 
>
> Suggested solution:
>
> move if - else out from all functions that checks for the $DB_SCHEMA value,
> and call ONE function to handle this logic. I.e. read and analyse the output
> from DATA_DIR and return the exact directory or local workdir with an
> informative warning.
>
> e.g.
>
> sub validate_datadir{
>  my $type = shift;
>  if( -d "$DATA_DIR."/$type" ) {
>    return "$DATA_DIR."/$type";
>  }
>  print "Warn fallback to local workdir ./$type"\n";
>  return "./$type";
> }
>   




More information about the Users mailing list