- Installation procedure, detect chan_sccp

This commit is contained in:
PhantomVl 2019-04-24 20:31:38 +03:00
parent 47f92a0c53
commit c23a697234
2 changed files with 26 additions and 6 deletions

View file

@ -195,6 +195,8 @@ class srvinterface {
return 0;
}
switch ($res["vCode"]) {
case 0:
return 0;
case 433:
return 433;
@ -229,6 +231,10 @@ class srvinterface {
$result = array();
$ast_out = $this->sccp_version();
$result["Version"] = $ast_out[0];
if ($ast_out[0] == '-1') {
$result["vCode"] = 0;
return $result;
}
$version_parts = explode(".", $ast_out[0]);
$result["vCode"] = implode('', $version_parts);
if (!empty($ast_out[1]) && $ast_out[1] == 'develop') {
@ -247,6 +253,9 @@ class srvinterface {
private function sccp_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)) {
$ast_out = substr($matches[0], 9, -1);
return explode(' ', $ast_out);

View file

@ -802,12 +802,12 @@ function CreateBackUpConfig() {
global $amp_conf;
outn("<li>" . _("Create Config BackUp") . "</li>");
$cnf_int = \FreePBX::Config();
$backup_files = array('extconfig','extconfig','res_mysql', 'res_config_mysql','sccp');
$backup_files = array('extensions','extconfig','res_mysql', 'res_config_mysql','sccp');
$backup_ext = array('_custom.conf', '.conf');
$dir = $cnf_int->get('ASTETCDIR');
$filename = $dir.'/sccp_backup_'.date("Ymd").'.sql';
$result = exec('mysqldump '.$amp_conf['AMPDBNAME'].' --password='.$amp_conf['AMPDBPASS'].' --user='.$amp_conf['AMPDBUSER'].' --single-transaction >'.$filename ,$output);
$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";
@ -819,10 +819,14 @@ function CreateBackUpConfig() {
}
}
}
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>");
}
@ -905,14 +909,21 @@ CheckSCCPManagerDBTables($table_req);
#CheckPermissions();
CheckAsteriskVersion();
$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);
$sccp_db_ver = CheckSCCPManagerDBVersion();
// BackUp Old config
CreateBackUpConfig();
if ($sccp_compatible > 431) {
InstallDB_sccpuser();
InstallDB_Buttons();
}
InstallDB_sccpsettings();
InstallDB_sccpdevmodel();