Changeset 2086

Show
Ignore:
Timestamp:
06/25/06 05:37:15 (6 years ago)
Author:
qldrob
Message:

Feature request #697 - Add support for a 'named' database, rather than just 'asterisk'. Changing asteriskcdrdb will be harder.

Files:

Legend:

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

    r2043 r2086  
    5151$hostname = "localhost"; 
    5252# the name of the database our tables are kept 
    53 $database = "asterisk"; 
     53# Now taken from $User_Preferences 
     54# $database = "asterisk"; 
    5455# scratch file to ftp results with 
    5556$ftpfile = "/tmp/freepbx-backup.ftp"; 
     
    7172# password to connect to the database 
    7273$password = $User_Preferences{"AMPDBPASS"}; 
     74# Database name 
     75$database = $User_Preferences{"AMPDBNAME"}; 
    7376# the WEB ROOT directory  
    7477$webroot = $User_Preferences{"AMPWEBROOT"}; 
  • freepbx/trunk/amp_conf/bin/retrieve_backup_cron_from_mysql.pl

    r912 r2086  
    3232# WARNING: this file will be substituted by the output of this program 
    3333$Backup_cron = "/etc/asterisk/backup.conf"; 
    34 # the name of the database our tables are kept 
    35 $database = "asterisk"; 
    3634 
    3735# cool hack by Julien BLACHE <jblache@debian.org> 
    3836$ampconf = parse_amportal_conf( "/etc/amportal.conf" ); 
     37 
     38################### END OF CONFIGURATION ####################### 
     39 
    3940# the name of the box the MySQL database is running on 
    4041$hostname = $ampconf->{"AMPDBHOST"}; 
    41  
    42 ################### END OF CONFIGURATION ####################### 
    43 open(FILE, "/etc/amportal.conf") || die "Failed to open amportal.conf\n"; 
    44 while (<FILE>) { 
    45     chomp;                  # no newline 
    46     s/#.*//;                # no comments 
    47     s/^\s+//;               # no leading white 
    48     s/\s+$//;               # no trailing white 
    49     next unless length;     # anything left? 
    50     my ($var, $value) = split(/\s*=\s*/, $_, 2); 
    51     $User_Preferences{$var} = $value; 
    52 }  
    53 close(FILE); 
    54  
    5542# username to connect to the database 
    56 $username = $User_Preferences{"AMPDBUSER"} ; 
     43$username = $ampconf->{"AMPDBUSER"} ; 
    5744# password to connect to the database 
    58 $password = $User_Preferences{"AMPDBPASS"};  
     45$password = $ampconf->{"AMPDBPASS"};  
     46# the name of the database our tables are kept 
     47$database = $ampconf->{"AMPDBNAME"}; 
    5948 
    6049 
  • freepbx/trunk/amp_conf/bin/retrieve_conf

    r1914 r2086  
    149149outn("Connecting to database.."); 
    150150 
    151 /* 
    152 $db_user = $amp_conf["AMPDBUSER"]; 
    153 $db_pass = $amp_conf["AMPDBPASS"]; 
    154 $db_host = $amp_conf["AMPDBHOST"]; 
    155 $db_name = 'asterisk'; 
    156 $db_engine = 'mysql'; 
    157  
    158 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
    159  
    160 if (!function_exists($db_engine.'_connect')) { 
    161   out("FAILED"); 
    162   fatal($db_engine." PHP libraries not installed"); 
    163 } 
    164  
    165 $db = DB::connect($datasource); // attempt connection 
    166 */ 
    167  
    168151# the engine to be used for the SQL queries, 
    169152# if none supplied, backfall to mysql 
     
    183166    $db_pass = $amp_conf["AMPDBPASS"]; 
    184167    $db_host = $amp_conf["AMPDBHOST"]; 
    185     $db_name = 'asterisk'
     168    $db_name = $amp_cond["AMPDBNAME"]
    186169   
    187170    $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
  • freepbx/trunk/amp_conf/bin/retrieve_iax_conf_from_mysql.pl

    r1712 r2086  
    2020# WARNING: this file will be substituted by the output of this program 
    2121$iax_conf = "/etc/asterisk/iax_additional.conf"; 
    22 # the name of the database our tables are kept 
    23 $database = "asterisk"; 
    2422 
    2523# cool hack by Julien BLACHE <jblache@debian.org> 
     
    3129# the name of the box the MySQL database is running on 
    3230$hostname = $ampconf->{"AMPDBHOST"}; 
     31# the name of the database our tables are kept 
     32$database = $ampconf->{"AMPDBNAME"}; 
    3333 
    3434# the engine to be used for the SQL queries, 
  • freepbx/trunk/amp_conf/bin/retrieve_op_conf_from_mysql.pl

    r1708 r2086  
    101101#@conferences=(@conferences,[ "811","Conf.11" ]); 
    102102 
    103  
    104 # the name of the database our tables are kept 
    105 $database = "asterisk"; 
    106  
    107103# cool hack by Julien BLACHE <jblache@debian.org> 
    108104$ampconf = parse_amportal_conf( "/etc/amportal.conf" ); 
     
    116112# the name of the box the MySQL database is running on 
    117113$hostname = $ampconf->{"AMPDBHOST"}; 
     114# the name of the database our tables are kept 
     115$database = $ampconf->{"AMPDBNAME"}; 
    118116#sort option: extension or lastname 
    119117$sortoption = $ampconf->{"FOPSORT"}; 
  • freepbx/trunk/amp_conf/bin/retrieve_queues_conf_from_mysql.pl

    r1019 r2086  
    1616# WARNING: this file will be substituted by the output of this program 
    1717$queues_conf = "/etc/asterisk/queues_additional.conf"; 
    18 # the name of the database our tables are kept 
    19 $database = "asterisk"; 
    2018 
    2119# cool hack by Julien BLACHE <jblache@debian.org> 
     
    2523# password to connect to the database 
    2624$password = $ampconf->{"AMPDBPASS"}; 
     25# the name of the database our tables are kept 
     26$database = $ampconf->{"AMPDBNAME"}; 
    2727# the name of the box the MySQL database is running on 
    2828$hostname = $ampconf->{"AMPDBHOST"}; 
  • freepbx/trunk/amp_conf/bin/retrieve_sip_conf_from_mysql.pl

    r1712 r2086  
    2020# WARNING: this file will be substituted by the output of this program 
    2121$sip_conf = "/etc/asterisk/sip_additional.conf"; 
    22 # the name of the database our tables are kept 
    23 $database = "asterisk"; 
    2422 
    2523# cool hack by Julien BLACHE <jblache@debian.org> 
     
    2927# password to connect to the database 
    3028$password = $ampconf->{"AMPDBPASS"}; 
     29# the name of the database our tables are kept 
     30$database = $ampconf->{"AMPDBNAME"}; 
    3131# the name of the box the MySQL database is running on 
    3232$hostname = $ampconf->{"AMPDBHOST"}; 
  • freepbx/trunk/amp_conf/bin/retrieve_zap_conf_from_mysql.pl

    r1712 r2086  
    2020# WARNING: this file will be substituted by the output of this program 
    2121$zap_conf = "/etc/asterisk/zapata_additional.conf"; 
    22 # the name of the database our tables are kept 
    23 $database = "asterisk"; 
    2422 
    2523# cool hack by Julien BLACHE <jblache@debian.org> 
     
    2927# password to connect to the database 
    3028$password = $ampconf->{"AMPDBPASS"}; 
     29# the name of the database our tables are kept 
     30$database = $ampconf->{"AMPDBNAME"}; 
    3131# the name of the box the MySQL database is running on 
    3232$hostname = $ampconf->{"AMPDBHOST"}; 
  • freepbx/trunk/amp_conf/htdocs/admin/common/db_connect.php

    r1004 r2086  
    2626    $db_pass = $amp_conf["AMPDBPASS"]; 
    2727    $db_host = $amp_conf["AMPDBHOST"]; 
    28     $db_name = 'asterisk'
     28    $db_name = $amp_conf["AMPDBNAME"]
    2929     
    3030    $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
  • freepbx/trunk/install_amp

    r2079 r2086  
    7474  out("  --force-version <ver>    Force upgrade from version <ver>"); 
    7575  out("  --dbhost <ip address>    Use a remote database server"); 
     76  out("  --dbname databasename    Use database name specified, instead of 'asterisk'"); 
    7677  out("  --no-files               Just run updates without installing files"); 
    7778} 
     
    418419/** Collect AMP settings 
    419420 */ 
    420 function collect_settings($filename, $dbhost = '', $dbuser = '', $dbpass = '') { 
     421function collect_settings($filename, $dbhost = '', $dbuser = '', $dbpass = '', $dbname = 'asterisk') { 
    421422  out("Creating new /etc/amportal.conf"); 
    422423   
    423   outn("Enter your USERNAME to connect to the 'asterisk' database:\n [".($dbuser ? $dbuser : "asteriskuser")."] "); 
     424  outn("Enter your USERNAME to connect to the '$dbname' database:\n [".($dbuser ? $dbuser : "asteriskuser")."] "); 
    424425  $key = trim(fgets(STDIN,1024)); 
    425426  if (preg_match('/^$/',$key)) $amp_conf["AMPDBUSER"] = ($dbuser ? $dbuser : "asteriskuser"); 
    426427  else $amp_conf["AMPDBUSER"] = $key; 
    427428   
    428   outn("Enter your PASSWORD to connect to the 'asterisk' database:\n [".($dbpass ? $dbpass : "amp109")."] "); 
     429  outn("Enter your PASSWORD to connect to the '$dbname' database:\n [".($dbpass ? $dbpass : "amp109")."] "); 
    429430  $key = trim(fgets(STDIN,1024)); 
    430431  if (preg_match('/^$/',$key)) $amp_conf["AMPDBPASS"] = ($dbpass ? $dbpass : "amp109"); 
    431432  else $amp_conf["AMPDBPASS"] = $key; 
    432433   
    433   outn("Enter the hostname of the 'asterisk' database:\n [".($dbhost ? $dbhost : "localhost")."] "); 
     434  outn("Enter the hostname of the '$dbname' database:\n [".($dbhost ? $dbhost : "localhost")."] "); 
    434435  $key = trim(fgets(STDIN,1024)); 
    435436  if (preg_match('/^$/',$key)) $amp_conf["AMPDBHOST"] = ($dbhost ? $dbhost : "localhost"); 
     
    567568// **** Parse out command-line options 
    568569$shortopts = "h?u:p:"; 
    569 $longopts = array("help","debug","dry-run","username=","password=","force-version=","dbhost=","no-files"); 
     570$longopts = array("help","debug","dry-run","username=","password=","force-version=","dbhost=","no-files","dbname="); 
    570571 
    571572$args = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), $shortopts, $longopts); 
     
    582583//initialize variables to avoid php notices 
    583584$dbhost = null;  
     585$dbname = null;  
    584586$new_username = null; 
    585587$new_password = null; 
     
    614616      $dbhost = $arg[1]; 
    615617      out("Using remote database server at ".$dbhost); 
     618    break; 
     619    case "--dbname": 
     620      $dbname = $arg[1]; 
     621      out("Using database ".$dbname); 
    616622    break; 
    617623    case "--no-files": 
     
    642648  out(AMP_CONF." does not exist, copying default"); 
    643649  copy("amportal.conf", "/etc/amportal.conf"); 
    644   collect_settings(AMP_CONF, $dbhost, $new_username, $new_password); 
     650  collect_settings(AMP_CONF, $dbhost, $new_username, $new_password, $dbname); 
    645651} 
    646652out("OK"); 
     
    657663// Ensure our "critical" variables are set.  We absolutely need these to copy in files. 
    658664 
    659 if (!array_key_exists("FOPWEBROOT",$amp_conf) ||  
    660   !array_key_exists("AMPBIN",$amp_conf) ||  
    661   !array_key_exists("AMPSBIN",$amp_conf) ||  
    662 //  !array_key_exists("AMPCGIBIN",$amp_conf) ||  
    663   !array_key_exists("AMPWEBROOT",$amp_conf) 
    664 ) { 
    665  
    666   if (!array_key_exists("AMPWEBROOT",$amp_conf)) { 
    667     out("Adding AMPWEBROOT option to amportal.conf - using AMP default"); 
    668     $amp_conf["AMPWEBROOT"] = "/var/www/html"; 
    669   } 
    670    
    671 //  if (!array_key_exists("AMPCGIBIN",$amp_conf)) { 
    672 //    out("Adding AMPCGIBIN option to amportal.conf - using AMP default"); 
    673 //    $amp_conf["AMPCGIBIN"] = "/var/www/cgi-bin"; 
    674 //  } 
    675    
    676   if (!array_key_exists("FOPWEBROOT",$amp_conf)) { 
    677     out("Adding FOPWEBROOT option to amportal.conf - using AMP default"); 
    678     $amp_conf["FOPWEBROOT"] = $amp_conf["AMPWEBROOT"]."/panel"; 
    679   } 
    680    
    681   if (!array_key_exists("AMPBIN",$amp_conf)) { 
    682     out("Adding AMPBIN option to amportal.conf - using AMP default"); 
    683     $amp_conf["AMPBIN"] = "/var/lib/asterisk/bin"; 
    684   } 
    685    
    686   if (!array_key_exists("AMPSBIN",$amp_conf)) { 
    687     out("Adding AMPSBIN option to amportal.conf - using AMP default"); 
    688     $amp_conf["AMPSBIN"] = "/usr/sbin"; 
    689   } 
    690    
    691   // write amportal.conf 
    692   write_amportal_conf(AMP_CONF, $amp_conf); 
    693 
    694  
    695 if (isset($new_username) || isset($new_password) || isset($dbhost)) { 
    696   // new username/pwd  
    697    
    698   if (isset($new_username)) { 
    699     $amp_conf["AMPDBUSER"] = $new_username; 
    700   } 
    701   if (isset($new_password)) { 
    702     $amp_conf["AMPDBPASS"] = $new_password; 
    703   } 
    704    
    705   if (isset($dbhost)) { 
    706     $amp_conf["AMPDBHOST"] = $dbhost; 
    707   } 
    708    
    709   // write amportal.conf 
    710   write_amportal_conf(AMP_CONF, $amp_conf); 
    711 
     665if (!array_key_exists("AMPWEBROOT",$amp_conf)) { 
     666  out("Adding AMPWEBROOT option to amportal.conf - using AMP default"); 
     667  $amp_conf["AMPWEBROOT"] = "/var/www/html"; 
     668
     669 
     670if (!array_key_exists("FOPWEBROOT",$amp_conf)) { 
     671  out("Adding FOPWEBROOT option to amportal.conf - using AMP default"); 
     672  $amp_conf["FOPWEBROOT"] = $amp_conf["AMPWEBROOT"]."/panel"; 
     673
     674 
     675if (!array_key_exists("AMPBIN",$amp_conf)) { 
     676  out("Adding AMPBIN option to amportal.conf - using AMP default"); 
     677  $amp_conf["AMPBIN"] = "/var/lib/asterisk/bin"; 
     678
     679 
     680if (!array_key_exists("AMPSBIN",$amp_conf)) { 
     681  out("Adding AMPSBIN option to amportal.conf - using AMP default"); 
     682  $amp_conf["AMPSBIN"] = "/usr/sbin"; 
     683
     684 
     685if (!array_key_exists("AMPDBENGINE",$amp_conf)) { 
     686  out("Adding AMPDBENGINE option to amportal.conf - using AMP default"); 
     687  $amp_conf["AMPDBENGINE"] = "mysql"; 
     688
     689if (!array_key_exists("AMPDBNAME",$amp_conf)) { 
     690  out("Adding AMPDBNAME option to amportal.conf - using AMP default"); 
     691  $amp_conf["AMPDBNAME"] = "asterisk"; 
     692
     693 
     694if (isset($new_username)) { 
     695  $amp_conf["AMPDBUSER"] = $new_username; 
     696
     697 
     698if (isset($new_password)) { 
     699  $amp_conf["AMPDBPASS"] = $new_password; 
     700
     701 
     702if (isset($dbhost)) { 
     703  $amp_conf["AMPDBHOST"] = $dbhost; 
     704
     705 
     706if (isset($dbname)) { 
     707  $amp_conf["AMPDBNAME"] = $dbname; 
     708
     709   
     710// write amportal.conf 
     711write_amportal_conf(AMP_CONF, $amp_conf); 
    712712 
    713713// **** Check for amportal.conf, create if necessary 
     
    717717  out(ASTERISK_CONF." does not exist, copying default"); 
    718718  copy("asterisk.conf", "/etc/asterisk/asterisk.conf"); 
    719   //TODO - need to prompt for asterisk specific directories - using * defaults for now 
    720   //collect_ast_settings(ASTERISK_CONF, $dbhost, $new_username, $new_password); 
    721719} 
    722720out("OK"); 
     
    766764$db_host = $amp_conf["AMPDBHOST"]; 
    767765$db_engine = $amp_conf["AMPDBENGINE"]; 
    768 $db_name = 'asterisk'
     766$db_name = $amp_conf["AMPDBNAME"]
    769767 
    770768// we still support older configurations,  and fall back