Changeset 2086
- Timestamp:
- 06/25/06 05:37:15 (6 years ago)
- Files:
-
- freepbx/trunk/amp_conf/bin/ampbackup.pl (modified) (2 diffs)
- freepbx/trunk/amp_conf/bin/retrieve_backup_cron_from_mysql.pl (modified) (1 diff)
- freepbx/trunk/amp_conf/bin/retrieve_conf (modified) (2 diffs)
- freepbx/trunk/amp_conf/bin/retrieve_iax_conf_from_mysql.pl (modified) (2 diffs)
- freepbx/trunk/amp_conf/bin/retrieve_op_conf_from_mysql.pl (modified) (2 diffs)
- freepbx/trunk/amp_conf/bin/retrieve_queues_conf_from_mysql.pl (modified) (2 diffs)
- freepbx/trunk/amp_conf/bin/retrieve_sip_conf_from_mysql.pl (modified) (2 diffs)
- freepbx/trunk/amp_conf/bin/retrieve_zap_conf_from_mysql.pl (modified) (2 diffs)
- freepbx/trunk/amp_conf/htdocs/admin/common/db_connect.php (modified) (1 diff)
- freepbx/trunk/install_amp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/bin/ampbackup.pl
r2043 r2086 51 51 $hostname = "localhost"; 52 52 # the name of the database our tables are kept 53 $database = "asterisk"; 53 # Now taken from $User_Preferences 54 # $database = "asterisk"; 54 55 # scratch file to ftp results with 55 56 $ftpfile = "/tmp/freepbx-backup.ftp"; … … 71 72 # password to connect to the database 72 73 $password = $User_Preferences{"AMPDBPASS"}; 74 # Database name 75 $database = $User_Preferences{"AMPDBNAME"}; 73 76 # the WEB ROOT directory 74 77 $webroot = $User_Preferences{"AMPWEBROOT"}; freepbx/trunk/amp_conf/bin/retrieve_backup_cron_from_mysql.pl
r912 r2086 32 32 # WARNING: this file will be substituted by the output of this program 33 33 $Backup_cron = "/etc/asterisk/backup.conf"; 34 # the name of the database our tables are kept35 $database = "asterisk";36 34 37 35 # cool hack by Julien BLACHE <jblache@debian.org> 38 36 $ampconf = parse_amportal_conf( "/etc/amportal.conf" ); 37 38 ################### END OF CONFIGURATION ####################### 39 39 40 # the name of the box the MySQL database is running on 40 41 $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 newline46 s/#.*//; # no comments47 s/^\s+//; # no leading white48 s/\s+$//; # no trailing white49 next unless length; # anything left?50 my ($var, $value) = split(/\s*=\s*/, $_, 2);51 $User_Preferences{$var} = $value;52 }53 close(FILE);54 55 42 # username to connect to the database 56 $username = $ User_Preferences{"AMPDBUSER"} ;43 $username = $ampconf->{"AMPDBUSER"} ; 57 44 # 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"}; 59 48 60 49 freepbx/trunk/amp_conf/bin/retrieve_conf
r1914 r2086 149 149 outn("Connecting to database.."); 150 150 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 connection166 */167 168 151 # the engine to be used for the SQL queries, 169 152 # if none supplied, backfall to mysql … … 183 166 $db_pass = $amp_conf["AMPDBPASS"]; 184 167 $db_host = $amp_conf["AMPDBHOST"]; 185 $db_name = 'asterisk';168 $db_name = $amp_cond["AMPDBNAME"]; 186 169 187 170 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; freepbx/trunk/amp_conf/bin/retrieve_iax_conf_from_mysql.pl
r1712 r2086 20 20 # WARNING: this file will be substituted by the output of this program 21 21 $iax_conf = "/etc/asterisk/iax_additional.conf"; 22 # the name of the database our tables are kept23 $database = "asterisk";24 22 25 23 # cool hack by Julien BLACHE <jblache@debian.org> … … 31 29 # the name of the box the MySQL database is running on 32 30 $hostname = $ampconf->{"AMPDBHOST"}; 31 # the name of the database our tables are kept 32 $database = $ampconf->{"AMPDBNAME"}; 33 33 34 34 # the engine to be used for the SQL queries, freepbx/trunk/amp_conf/bin/retrieve_op_conf_from_mysql.pl
r1708 r2086 101 101 #@conferences=(@conferences,[ "811","Conf.11" ]); 102 102 103 104 # the name of the database our tables are kept105 $database = "asterisk";106 107 103 # cool hack by Julien BLACHE <jblache@debian.org> 108 104 $ampconf = parse_amportal_conf( "/etc/amportal.conf" ); … … 116 112 # the name of the box the MySQL database is running on 117 113 $hostname = $ampconf->{"AMPDBHOST"}; 114 # the name of the database our tables are kept 115 $database = $ampconf->{"AMPDBNAME"}; 118 116 #sort option: extension or lastname 119 117 $sortoption = $ampconf->{"FOPSORT"}; freepbx/trunk/amp_conf/bin/retrieve_queues_conf_from_mysql.pl
r1019 r2086 16 16 # WARNING: this file will be substituted by the output of this program 17 17 $queues_conf = "/etc/asterisk/queues_additional.conf"; 18 # the name of the database our tables are kept19 $database = "asterisk";20 18 21 19 # cool hack by Julien BLACHE <jblache@debian.org> … … 25 23 # password to connect to the database 26 24 $password = $ampconf->{"AMPDBPASS"}; 25 # the name of the database our tables are kept 26 $database = $ampconf->{"AMPDBNAME"}; 27 27 # the name of the box the MySQL database is running on 28 28 $hostname = $ampconf->{"AMPDBHOST"}; freepbx/trunk/amp_conf/bin/retrieve_sip_conf_from_mysql.pl
r1712 r2086 20 20 # WARNING: this file will be substituted by the output of this program 21 21 $sip_conf = "/etc/asterisk/sip_additional.conf"; 22 # the name of the database our tables are kept23 $database = "asterisk";24 22 25 23 # cool hack by Julien BLACHE <jblache@debian.org> … … 29 27 # password to connect to the database 30 28 $password = $ampconf->{"AMPDBPASS"}; 29 # the name of the database our tables are kept 30 $database = $ampconf->{"AMPDBNAME"}; 31 31 # the name of the box the MySQL database is running on 32 32 $hostname = $ampconf->{"AMPDBHOST"}; freepbx/trunk/amp_conf/bin/retrieve_zap_conf_from_mysql.pl
r1712 r2086 20 20 # WARNING: this file will be substituted by the output of this program 21 21 $zap_conf = "/etc/asterisk/zapata_additional.conf"; 22 # the name of the database our tables are kept23 $database = "asterisk";24 22 25 23 # cool hack by Julien BLACHE <jblache@debian.org> … … 29 27 # password to connect to the database 30 28 $password = $ampconf->{"AMPDBPASS"}; 29 # the name of the database our tables are kept 30 $database = $ampconf->{"AMPDBNAME"}; 31 31 # the name of the box the MySQL database is running on 32 32 $hostname = $ampconf->{"AMPDBHOST"}; freepbx/trunk/amp_conf/htdocs/admin/common/db_connect.php
r1004 r2086 26 26 $db_pass = $amp_conf["AMPDBPASS"]; 27 27 $db_host = $amp_conf["AMPDBHOST"]; 28 $db_name = 'asterisk';28 $db_name = $amp_conf["AMPDBNAME"]; 29 29 30 30 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; freepbx/trunk/install_amp
r2079 r2086 74 74 out(" --force-version <ver> Force upgrade from version <ver>"); 75 75 out(" --dbhost <ip address> Use a remote database server"); 76 out(" --dbname databasename Use database name specified, instead of 'asterisk'"); 76 77 out(" --no-files Just run updates without installing files"); 77 78 } … … 418 419 /** Collect AMP settings 419 420 */ 420 function collect_settings($filename, $dbhost = '', $dbuser = '', $dbpass = '' ) {421 function collect_settings($filename, $dbhost = '', $dbuser = '', $dbpass = '', $dbname = 'asterisk') { 421 422 out("Creating new /etc/amportal.conf"); 422 423 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")."] "); 424 425 $key = trim(fgets(STDIN,1024)); 425 426 if (preg_match('/^$/',$key)) $amp_conf["AMPDBUSER"] = ($dbuser ? $dbuser : "asteriskuser"); 426 427 else $amp_conf["AMPDBUSER"] = $key; 427 428 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")."] "); 429 430 $key = trim(fgets(STDIN,1024)); 430 431 if (preg_match('/^$/',$key)) $amp_conf["AMPDBPASS"] = ($dbpass ? $dbpass : "amp109"); 431 432 else $amp_conf["AMPDBPASS"] = $key; 432 433 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")."] "); 434 435 $key = trim(fgets(STDIN,1024)); 435 436 if (preg_match('/^$/',$key)) $amp_conf["AMPDBHOST"] = ($dbhost ? $dbhost : "localhost"); … … 567 568 // **** Parse out command-line options 568 569 $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="); 570 571 571 572 $args = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), $shortopts, $longopts); … … 582 583 //initialize variables to avoid php notices 583 584 $dbhost = null; 585 $dbname = null; 584 586 $new_username = null; 585 587 $new_password = null; … … 614 616 $dbhost = $arg[1]; 615 617 out("Using remote database server at ".$dbhost); 618 break; 619 case "--dbname": 620 $dbname = $arg[1]; 621 out("Using database ".$dbname); 616 622 break; 617 623 case "--no-files": … … 642 648 out(AMP_CONF." does not exist, copying default"); 643 649 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); 645 651 } 646 652 out("OK"); … … 657 663 // Ensure our "critical" variables are set. We absolutely need these to copy in files. 658 664 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 } 665 if (!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 670 if (!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 675 if (!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 680 if (!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 685 if (!array_key_exists("AMPDBENGINE",$amp_conf)) { 686 out("Adding AMPDBENGINE option to amportal.conf - using AMP default"); 687 $amp_conf["AMPDBENGINE"] = "mysql"; 688 } 689 if (!array_key_exists("AMPDBNAME",$amp_conf)) { 690 out("Adding AMPDBNAME option to amportal.conf - using AMP default"); 691 $amp_conf["AMPDBNAME"] = "asterisk"; 692 } 693 694 if (isset($new_username)) { 695 $amp_conf["AMPDBUSER"] = $new_username; 696 } 697 698 if (isset($new_password)) { 699 $amp_conf["AMPDBPASS"] = $new_password; 700 } 701 702 if (isset($dbhost)) { 703 $amp_conf["AMPDBHOST"] = $dbhost; 704 } 705 706 if (isset($dbname)) { 707 $amp_conf["AMPDBNAME"] = $dbname; 708 } 709 710 // write amportal.conf 711 write_amportal_conf(AMP_CONF, $amp_conf); 712 712 713 713 // **** Check for amportal.conf, create if necessary … … 717 717 out(ASTERISK_CONF." does not exist, copying default"); 718 718 copy("asterisk.conf", "/etc/asterisk/asterisk.conf"); 719 //TODO - need to prompt for asterisk specific directories - using * defaults for now720 //collect_ast_settings(ASTERISK_CONF, $dbhost, $new_username, $new_password);721 719 } 722 720 out("OK"); … … 766 764 $db_host = $amp_conf["AMPDBHOST"]; 767 765 $db_engine = $amp_conf["AMPDBENGINE"]; 768 $db_name = 'asterisk';766 $db_name = $amp_conf["AMPDBNAME"]; 769 767 770 768 // we still support older configurations, and fall back
