Changeset 2075

Show
Ignore:
Timestamp:
06/22/06 02:46:24 (4 years ago)
Author:
diego_iastrubni
Message:

1) improoves the sqlite support. now we can generate the first time install using this script. with some luck it will even support pgsql. the syntax
is there, we just need someone with pgsql knowlege to test this this.

2) removed remarks about the perl checking code, since it's obsolete, no need for maintaining this right...?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.1/install_amp

    r1989 r2075  
    564564out("OK"); 
    565565 
    566 /* RC: WE SOULDN'T NEED THESE WITH NEW PHP DIALPARTIES 
    567 // **** Make sure we have libasteriskperl 
    568 $perl_test = "perl -e 'use Asterisk::AGI'"; 
    569 outn( "Checking for libasteriskperl (perl bindings for asterisk)..." ); 
    570 exec( " $perl_test &> /dev/null", $perl_output, $perl_result ); 
    571 if ( $perl_result != 0) 
    572 { 
    573         out("FAILED\nReturn code from \"$perl_test\" is: " . $perl_result ); 
    574         fatal( "Please install libasteriskperl from your vendor.\nThis perl module is needed for executing dialparties.agi." ); 
    575 } 
    576 out("OK"); 
    577  
    578 // **** Make sure we have Net::Telnet 
    579 $perl_test = "perl -e 'use Net::Telnet'"; 
    580 outn( "Checking for Net::Telnet (used by dialparties.agi)..." ); 
    581 exec( " $perl_test &> /dev/null", $perl_output, $perl_result ); 
    582 if ( $perl_result != 0) 
    583 { 
    584         out("FAILED\nReturn code from \"$perl_test\" is: " . $perl_result ); 
    585         fatal( "Please install Net::Telnet from your vendor or CPAN.\nThis perl module is needed for executing dialparties.agi." ); 
    586 } 
    587 out("OK"); 
    588 */ 
    589  
    590566// **** Parse out command-line options 
    591  
    592567$shortopts = "h?u:p:"; 
    593568$longopts = array("help","debug","dry-run","username=","password=","force-version=","dbhost=","no-files"); 
     
    789764$db_pass = $amp_conf["AMPDBPASS"]; 
    790765$db_host = $amp_conf["AMPDBHOST"]; 
     766$db_engine = $amp_conf["AMPDBENGINE"]; 
    791767$db_name = 'asterisk'; 
    792 $db_engine = 'mysql'; 
    793  
    794 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
    795  
    796 if (!function_exists($db_engine.'_connect')) { 
    797         out("FAILED"); 
    798         fatal($db_engine." PHP libraries not installed"); 
    799 
    800  
    801 $db = DB::connect($datasource); // attempt connection 
     768 
     769// we still support older configurations,  and fall back  
     770// into mysql when no other engine is defined 
     771if ($db_engine == "") 
     772
     773        $db_engine = "mysql"; 
     774
     775         
     776switch ($db_engine) 
     777
     778        case "pgsql": 
     779        case "mysql": 
     780                // datasource in in this style: dbengine://username:password@host/database  
     781                if (!function_exists($db_engine.'_connect')) { 
     782                        out("FAILED"); 
     783                        fatal($db_engine." PHP libraries not installed"); 
     784                } 
     785         
     786                $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
     787                $db = DB::connect($datasource); // attempt connection 
     788                break; 
     789         
     790        case "sqlite": 
     791                if (! @ include('DB/sqlite.php')) 
     792                { 
     793                        out("FAILED"); 
     794                        fatal( "Your PHP installation lacks SQLite support" ); 
     795                } 
     796         
     797                if (!isset($amp_conf["AMPDBFILE"])) 
     798                        die("You must setup properly AMPDBFILE in /etc/amportal.conf"); 
     799         
     800                if (isset($amp_conf["AMPDBFILE"]) == "") 
     801                        die("AMPDBFILE in /etc/amportal.conf cannot be blank"); 
     802         
     803                $DSN = array ( 
     804                        "database" => $amp_conf["AMPDBFILE"], 
     805                        "mode" => 0666 
     806                ); 
     807         
     808                $db = new DB_sqlite(); 
     809                $db->connect( $DSN ); 
     810                break; 
     811         
     812        default: 
     813                die( "Unknown SQL engine: [$db_engine]"); 
     814
    802815 
    803816if(DB::isError($db)) {