Show
Ignore:
Timestamp:
03/06/06 10:07:41 (7 years ago)
Author:
diego_iastrubni
Message:

oops... sqlite support on the site is quite cool, but if you cannot generate the configuration freepbx sux0rz...

with this patch the retriev*.pl files now get the config from sqlite as well. I also fixed some wierd bugs on the files, and not if the connection
to the sql cannot be done, the script will abort before writing any configuration (before it would leave you with a zero length configuration).

please test, works on my setup... but who knows..., I am only testing on sqlite :)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freepbx/amp_conf/bin/retrieve_iax_conf_from_mysql.pl

    r912 r1019  
    3232$hostname = $ampconf->{"AMPDBHOST"}; 
    3333 
     34# the engine to be used for the SQL queries, 
     35# if none supplied, backfall to mysql 
     36$db_engine = "mysql"; 
     37if (exists($ampconf->{"AMPDBENGINE"})) { 
     38  $db_engine = $ampconf->{"AMPDBENGINE"}; 
     39} 
    3440 
    3541################### END OF CONFIGURATION ####################### 
    3642 
    37 $additional = ""; 
    38  
    39 open EXTEN, ">$iax_conf" or die "Cannot create/overwrite extensions file: $iax_conf\n"; 
    40  
    41 $dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password"); 
     43if ( $db_engine eq "mysql" ) { 
     44  $dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password"); 
     45
     46elsif ( $db_engine eq "pgsql" ) { 
     47  $dbh = DBI->connect("dbi:pgsql:dbname=$database;host=$hostname", "$username", "$password"); 
     48
     49elsif ( $db_engine eq "sqlite" ) { 
     50  if (!exists($ampconf->{"AMPDBFILE"})) { 
     51    print "No AMPDBFILE set in /etc/amportal.conf\n"; 
     52    exit; 
     53  } 
     54   
     55  my $db_file = $ampconf->{"AMPDBFILE"}; 
     56  $dbh = DBI->connect("dbi:SQLite2:dbname=$db_file","",""); 
     57
    4258 
    4359# items with id=0 get added for all users 
     
    5167  exit; 
    5268} 
     69 
     70open EXTEN, ">$iax_conf" or die "Cannot create/overwrite extensions file: $iax_conf\n"; 
     71$additional = ""; 
    5372my @resultSet = @{$result}; 
    5473if ( $#resultSet > -1 ) {