From 2fbd4e2aaef2cb876bd7827e95876d383a0a61b5 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 11:23:52 +0000 Subject: [PATCH 1/8] Added check will now throw if the config.lua could not be opened for writing --- core/databases/app_defaults.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/databases/app_defaults.php b/core/databases/app_defaults.php index ea4d04d6c9..71adfaced2 100644 --- a/core/databases/app_defaults.php +++ b/core/databases/app_defaults.php @@ -126,6 +126,9 @@ if ($domains_processed == 1) { $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; } $fout = fopen($config,"w"); + if(!$fout){ + throw new Exception("Failed to open '$config' for writing"); + } $tmp = "\n"; $tmp .= "--set the variables\n"; if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { From ebadb3b09f4100203a0a1fc394e1966b2de9bab4 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 13:20:04 +0000 Subject: [PATCH 2/8] fixed detection of timezone on debian removed add_new_switch temporarily, currently not supported --- core/install/index.php | 15 --------------- core/install/install_first_time.php | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/core/install/index.php b/core/install/index.php index 9011dd9574..1eb6efc8c9 100644 --- a/core/install/index.php +++ b/core/install/index.php @@ -78,21 +78,6 @@ if (!if_group("superadmin")) { echo "\n"; echo "\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
\n"; - echo " "; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo "

"; echo "

WiP

"; diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index b4366275fa..1416d39f69 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -63,7 +63,7 @@ if (is_link('/etc/localtime')) { // Ubuntu / Debian. $data = file_get_contents('/etc/timezone'); if ($data) { - $timezone = $data; + $timezone = rtrim($data); } } elseif (file_exists('/etc/sysconfig/clock')) { // RHEL / CentOS From ad60f62e60afaa9eee100442f69fef05c91ee3db Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 14:33:08 +0000 Subject: [PATCH 3/8] Corrected storage of the event_port made a warning render correctly added a warning about choosing a remote host --- core/install/install_first_time.php | 10 ++++++++++ .../resources/page_parts/install_config_database.php | 2 +- .../resources/page_parts/install_config_detail.php | 2 +- .../resources/page_parts/install_event_socket.php | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 1416d39f69..43311d541e 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -224,6 +224,9 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo "\n"; }elseif($install_step == 'detect_config'){ + if(!($event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1')){ + echo "

Warning you have choosen a value other than localhost for event_host, this is unsoported at present

\n"; + } include "resources/page_parts/install_event_socket.php"; if($detect_ok){ echo "
\n"; @@ -238,6 +241,12 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo " \n"; echo "
\n"; + }else{ + echo "
\n"; + echo "
\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; } } elseif($install_step == 'config_detail'){ @@ -257,6 +266,7 @@ if(!$install_step) { $install_step = 'select_language'; } //if($_SERVER['HTTPS']) { $protocol = 'https'; } //echo ""; require_once "core/install/resources/classes/detect_switch.php"; + trigger_error("D:> using $event_host, $event_port, $event_password\n",E_USER_WARNING); $switch_detect = new detect_switch($event_host, $event_port, $event_password); $detect_ok = true; try { diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index ad8e632734..371a726b98 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -31,7 +31,7 @@ echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/core/install/resources/page_parts/install_config_detail.php b/core/install/resources/page_parts/install_config_detail.php index 8ee7597ba9..6fd2c8ce05 100644 --- a/core/install/resources/page_parts/install_config_detail.php +++ b/core/install/resources/page_parts/install_config_detail.php @@ -31,7 +31,7 @@ echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; diff --git a/core/install/resources/page_parts/install_event_socket.php b/core/install/resources/page_parts/install_event_socket.php index 7122925b4d..8588d13b1e 100644 --- a/core/install/resources/page_parts/install_event_socket.php +++ b/core/install/resources/page_parts/install_event_socket.php @@ -31,10 +31,10 @@ try { $switch_detect->detect(); } catch(Exception $e){ - $messages[] = "Failed to detect confgiuration detect_switch reported: " . $e->getMessage(); + echo "

Failed to detect configuration detect_switch reported: " . $e->getMessage() ."

\n"; $detect_ok = false; } - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "
\n"; From f0008691eeb207727a9f6ad43a936e879ddebbd0 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 14:56:56 +0000 Subject: [PATCH 4/8] moved fusionPBX install after switch install --- core/install/install_first_time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 311a36091a..30452fcf8c 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -294,7 +294,6 @@ if(!$install_step) { $install_step = 'select_language'; } require_once "resources/classes/install_fusionpbx.php"; $fusionPBX = new install_fusionpbx($domain_name, null, $switch_detect); $domain_uuid = $fusionPBX->domain_uuid(); - //$fusionPBX->debug = true; $fusionPBX->admin_username = $admin_username; $fusionPBX->admin_password = $admin_password; $fusionPBX->default_country = $install_default_country; @@ -305,12 +304,13 @@ if(!$install_step) { $install_step = 'select_language'; } $fusionPBX->$key = $value; } } - $fusionPBX->install(); require_once "resources/classes/install_switch.php"; $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; + //$fusionPBX->debug = true; $switch->install(); + $fusionPBX->install(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; From af867043b20fd336215a84273d218e89b1fdbd5f Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 15:57:32 +0000 Subject: [PATCH 5/8] changed install order --- core/install/install_first_time.php | 6 +++--- core/install/resources/classes/install_fusionpbx.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 30452fcf8c..e31be9e062 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -221,7 +221,7 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo "\n"; }elseif($install_step == 'detect_config'){ - if(!($event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1')){ + if(!($event_host == '' || $event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1' )){ echo "

Warning you have choosen a value other than localhost for event_host, this is unsoported at present

\n"; } include "resources/page_parts/install_event_socket.php"; @@ -263,7 +263,6 @@ if(!$install_step) { $install_step = 'select_language'; } //if($_SERVER['HTTPS']) { $protocol = 'https'; } //echo ""; require_once "core/install/resources/classes/detect_switch.php"; - trigger_error("D:> using $event_host, $event_port, $event_password\n",E_USER_WARNING); $switch_detect = new detect_switch($event_host, $event_port, $event_password); $detect_ok = true; try { @@ -309,8 +308,9 @@ if(!$install_step) { $install_step = 'select_language'; } $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; //$fusionPBX->debug = true; - $switch->install(); $fusionPBX->install(); + $switch->install(); + $fusionPBX->app_defaults(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 6d62060939..9c70cb7b2c 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -94,7 +94,6 @@ include "root.php"; $this->create_superuser(); require "resources/require.php"; $this->create_menus(); - $this->app_defaults(); } protected function create_config_php() { From e504c8b5926bfbbfe0fbb7f8c7e10f9b5d22f1dd Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 16:57:34 +0000 Subject: [PATCH 6/8] moved restart and unprotected app_defaults --- core/install/install_first_time.php | 1 + core/install/resources/classes/install_fusionpbx.php | 2 +- core/install/resources/classes/install_switch.php | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index e31be9e062..99f0ab043a 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -311,6 +311,7 @@ if(!$install_step) { $install_step = 'select_language'; } $fusionPBX->install(); $switch->install(); $fusionPBX->app_defaults(); + $detect_switch->restart_switch(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 9c70cb7b2c..57ee0c6403 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -975,7 +975,7 @@ include "root.php"; } } - protected function app_defaults() { + public function app_defaults() { $this->write_progress("Running app_defaults"); //set needed session settings diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index 97b12dd37a..715c2cef5b 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -176,9 +176,6 @@ include "root.php"; function install() { $this->copy_conf(); $this->copy_scripts(); - //tell freeswitch to restart - $this->write_progress("Restarting switch"); - $this->detect_switch->restart_switch(); } function upgrade() { From 5960b18e71d6866709d8c11f293ae127771e1659 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 17:53:02 +0000 Subject: [PATCH 7/8] Corrected incorrect merge --- core/upgrade/app_defaults.php | 6 ++---- core/upgrade/index.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php index b5625f3e7a..a904361bb8 100644 --- a/core/upgrade/app_defaults.php +++ b/core/upgrade/app_defaults.php @@ -34,10 +34,8 @@ if ($domains_processed == 1) { } //copy the files and directories from resources/install - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); + $obj = new install_switch; + $obj->upgrade(); } //update the software table diff --git a/core/upgrade/index.php b/core/upgrade/index.php index ef686b4b33..6a83f51e10 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -72,10 +72,8 @@ if (sizeof($_POST) > 0) { //update scripts folder, if allowed (default) if ($_SESSION['switch']['scripts']['dir'] != '') { //copy the files and directories from resources/install - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); + $obj = new install_switch; + $obj->upgrade(); //set the message $response_message = $text['message-upgrade_source_scripts']; } From b5eed9f0ef6761e4393d04e2f981c2d48c3ae129 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 18:12:35 +0000 Subject: [PATCH 8/8] populate event_socket_* for core/upgrade/app_defaults --- core/install/resources/classes/install_fusionpbx.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 57ee0c6403..ebfccc3de1 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -983,7 +983,10 @@ include "root.php"; $_SESSION["domain_uuid"] = $this->_domain_uuid; require $this->config_php; require "resources/require.php"; - + $_SESSION['event_socket_ip_address'] = $this->detect_switch->event_host; + $_SESSION['event_socket_port'] = $this->detect_switch->event_port; + $_SESSION['event_socket_password'] = $this->detect_switch->event_password; + //get the groups assigned to the user and then set the groups in $_SESSION["groups"] $sql = "SELECT * FROM v_group_users "; $sql .= "where domain_uuid=:domain_uuid ";