From cb440de264983f4f9698cb0fb346c079756dc0be Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 10 Dec 2015 10:51:38 +0000 Subject: [PATCH 1/2] updated switch version detection will now work with both git and packaged version numbers added bits to detect_switch --- app/system/system.php | 2 +- core/install/resources/classes/detect_switch.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/system/system.php b/app/system/system.php index 9129f39707..60cea81bb0 100644 --- a/app/system/system.php +++ b/app/system/system.php @@ -108,7 +108,7 @@ $document['title'] = $text['title-sys-status']; $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_version = event_socket_request($fp, 'api version'); - preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(\s*(\d+\w+)\s*\)/", $switch_version, $matches); + preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(.*?(\d+\w+)\s*\)/", $switch_version, $matches); $switch_version = $matches[1]; $switch_bits = $matches[2]; echo "\n"; diff --git a/core/install/resources/classes/detect_switch.php b/core/install/resources/classes/detect_switch.php index 4245d5bc61..92ab726465 100644 --- a/core/install/resources/classes/detect_switch.php +++ b/core/install/resources/classes/detect_switch.php @@ -40,10 +40,12 @@ require_once "resources/classes/EventSocket.php"; protected $_major; protected $_minor; protected $_build; + protected $_bits; public function major() { return $this->_major; } public function minor() { return $this->_minor; } public function build() { return $this->_build; } - public function version() { return $this->_major.".".$this->_minor.".".$this->_build; } + public function bits() { return $this->_bits; } + public function version() { return $this->_major.".".$this->_minor.".".$this->_build." (".$this->_bits.")"; } // dirs - detected by from the switch protected $_base_dir = ''; @@ -126,7 +128,7 @@ require_once "resources/classes/EventSocket.php"; throw new Exception('Failed to use event socket'); } $FS_Version = $this->event_socket_request('api version'); - preg_match("/FreeSWITCH Version (\d+)\.(\d+)\.(\d+(?:\.\d+)?)/", $FS_Version, $matches); + preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(.*?(\d+\w+)\s*\)/", $FS_Version, $matches); $this->_major = $matches[1]; $this->_minor = $matches[2]; $this->_build = $matches[3]; From 4776ceb0303021db63eb236bcf214034530537c3 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 10 Dec 2015 11:58:09 +0000 Subject: [PATCH 2/2] added switch git_info where available --- app/system/app_languages.php | 18 +++++++++--------- app/system/system.php | 12 +++++++++++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/system/app_languages.php b/app/system/app_languages.php index e576287a32..08271e3487 100644 --- a/app/system/app_languages.php +++ b/app/system/app_languages.php @@ -100,15 +100,15 @@ $text['label-git_info']['sv-se'] = ""; $text['label-git_info']['uk'] = ""; $text['label-git_info']['de-at'] = ""; -$text['label-switch_version']['en-us'] = "Switch Version"; -$text['label-switch_version']['es-cl'] = ""; -$text['label-switch_version']['pt-pt'] = ""; -$text['label-switch_version']['fr-fr'] = ""; -$text['label-switch_version']['pt-br'] = ""; -$text['label-switch_version']['pl'] = ""; -$text['label-switch_version']['sv-se'] = ""; -$text['label-switch_version']['uk'] = ""; -$text['label-switch_version']['de-at'] = ""; +$text['label-switch']['en-us'] = "Switch"; +$text['label-switch']['es-cl'] = ""; +$text['label-switch']['pt-pt'] = ""; +$text['label-switch']['fr-fr'] = ""; +$text['label-switch']['pt-br'] = ""; +$text['label-switch']['pl'] = ""; +$text['label-switch']['sv-se'] = ""; +$text['label-switch']['uk'] = ""; +$text['label-switch']['de-at'] = ""; $text['label-git_branch']['en-us'] = "Branch:"; $text['label-git_branch']['es-cl'] = ""; diff --git a/app/system/system.php b/app/system/system.php index 60cea81bb0..f9e63ce403 100644 --- a/app/system/system.php +++ b/app/system/system.php @@ -113,10 +113,20 @@ $document['title'] = $text['title-sys-status']; $switch_bits = $matches[2]; echo "\n"; echo " \n"; - echo " ".$text['label-switch_version']."\n"; + echo " ".$text['label-switch']." ".$text['label-version']."\n"; echo " \n"; echo " $switch_version ($switch_bits)\n"; echo "\n"; + preg_match("/\(git\s*(.*?)\s*\d+\w+\s*\)/", $switch_version, $matches); + $switch_git_info = $matches[1]; + if(strlen($switch_git_info) > 0){ + echo "\n"; + echo " \n"; + echo " ".$text['label-switch']." ".$text['label-git_info']."\n"; + echo " \n"; + echo " $switch_git_info\n"; + echo "\n"; + } } echo "