- Installation procedure, detect chan_sccp

This commit is contained in:
PhantomVl 2019-04-26 09:46:55 +03:00
parent 83169b5160
commit 6e81e98dbb
2 changed files with 51 additions and 0 deletions

View file

@ -200,6 +200,8 @@ class srvinterface {
return 0; return 0;
} }
switch ($res["vCode"]) { switch ($res["vCode"]) {
case 0:
return 0;
case 433: case 433:
return 433; return 433;
@ -234,6 +236,10 @@ class srvinterface {
$result = array(); $result = array();
$ast_out = $this->sccp_version(); $ast_out = $this->sccp_version();
$result["Version"] = $ast_out[0]; $result["Version"] = $ast_out[0];
if ($ast_out[0] == '-1') {
$result["vCode"] = 0;
return $result;
}
$version_parts = explode(".", $ast_out[0]); $version_parts = explode(".", $ast_out[0]);
$result["vCode"] = implode('', $version_parts); $result["vCode"] = implode('', $version_parts);
if (!empty($ast_out[1]) && $ast_out[1] == 'develop') { if (!empty($ast_out[1]) && $ast_out[1] == 'develop') {
@ -252,6 +258,9 @@ class srvinterface {
private function sccp_version() { private function sccp_version() {
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_version')); $ast_out = $this->sccp_core_commands(array('cmd' => 'get_version'));
if ( ($ast_out['Response'] == 'Error') || (strpos($ast_out['data'], 'No such command') != false) ) {
return array('-1');
}
if (preg_match("/Release.*\(/", $ast_out['data'], $matches)) { if (preg_match("/Release.*\(/", $ast_out['data'], $matches)) {
$ast_out = substr($matches[0], 9, -1); $ast_out = substr($matches[0], 9, -1);
return explode(' ', $ast_out); return explode(' ', $ast_out);

View file

@ -592,6 +592,8 @@ function InstallDB_createButtonConfigTrigger() {
if (DB::IsError($check)) { if (DB::IsError($check)) {
die_freepbx("Can not modify sccpdevice table\n"); die_freepbx("Can not modify sccpdevice table\n");
} }
outn("<li>" . _("(Re)Create trigger Ok") . "</li>");
// outn("<li>" . $sql . "</li>");
return true; return true;
} }
function InstallDB_updateDBVer($sccp_compatible) { function InstallDB_updateDBVer($sccp_compatible) {
@ -650,6 +652,37 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) {
} }
return true; return true;
} }
function CreateBackUpConfig() {
global $amp_conf;
outn("<li>" . _("Create Config BackUp") . "</li>");
$cnf_int = \FreePBX::Config();
$backup_files = array('extensions','extconfig','res_mysql', 'res_config_mysql','sccp');
$backup_ext = array('_custom.conf', '.conf');
$dir = $cnf_int->get('ASTETCDIR');
$fsql = $dir.'/sccp_backup_'.date("Ymd").'.sql';
$result = exec('mysqldump '.$amp_conf['AMPDBNAME'].' --password='.$amp_conf['AMPDBPASS'].' --user='.$amp_conf['AMPDBUSER'].' --single-transaction >'.$fsql ,$output);
$zip = new \ZipArchive();
$filename = $dir . "/sccp_instal_backup" . date("Ymd"). ".zip";
if ($zip->open($filename, \ZIPARCHIVE::CREATE)) {
foreach ($backup_files as $file) {
foreach ($backup_ext as $b_ext) {
if (file_exists($dir . '/'.$file . $b_ext)) {
$zip->addFile($dir . '/'.$file . $b_ext);
}
}
}
if (file_exists($fsql)) {
$zip->addFile($fsql);
}
$zip->close();
} else {
outn("<li>" . _("Error Create BackUp: ") . $filename ."</li>");
}
unlink($fsql);
outn("<li>" . _("Create Config BackUp: ") . $filename ."</li>");
}
function Setup_RealTime() { function Setup_RealTime() {
global $amp_conf; global $amp_conf;
@ -730,8 +763,17 @@ CheckSCCPManagerDBTables($table_req);
#CheckPermissions(); #CheckPermissions();
CheckAsteriskVersion(); CheckAsteriskVersion();
$sccp_compatible = CheckChanSCCPCompatible(); $sccp_compatible = CheckChanSCCPCompatible();
if ($sccp_compatible == 0) {
// die_freepbx('Chan Sccp not Found. Install it before continuing');
outn("<br>");
outn("<font color='red'>Chan Sccp not Found. Install it before continuing !</font>");
die();
}
$db_config = Get_DB_config($sccp_compatible); $db_config = Get_DB_config($sccp_compatible);
$sccp_db_ver = CheckSCCPManagerDBVersion(); $sccp_db_ver = CheckSCCPManagerDBVersion();
// BackUp Old config
CreateBackUpConfig();
InstallDB_sccpsettings(); InstallDB_sccpsettings();
InstallDB_sccpdevmodel(); InstallDB_sccpdevmodel();
InstallDB_updateSchema($db_config); InstallDB_updateSchema($db_config);