Initial add of feature mobility user table:

- Add extra user fields and sccp_config entries
 - Create new buttonconfig table
 - Add PhoneCodepages like cp1251
 - Add BackUp Config before Install
This commit is contained in:
PhantomVl 2019-03-25 18:16:17 +03:00 committed by Diederik de Groot
parent f4d2396a3c
commit 7582061645
No known key found for this signature in database
GPG key ID: AFA728250A1BECD6
2 changed files with 32 additions and 27 deletions

View file

@ -714,7 +714,8 @@ DELIMITER ;";*/
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>" . $sql . "</li>"); 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) {
@ -797,13 +798,9 @@ function CreateBackUpConfig() {
global $amp_conf; global $amp_conf;
outn("<li>" . _("Create Config BackUp") . "</li>"); outn("<li>" . _("Create Config BackUp") . "</li>");
$cnf_int = \FreePBX::Config(); $cnf_int = \FreePBX::Config();
$backup_files = array('extensions','extconfig','res_mysql', 'res_config_mysql','sccp','sccp_hardware','sccp_extensions'); $backup_files = array('extconfig','extconfig','res_mysql', 'res_config_mysql','sccp');
$backup_ext = array('_custom.conf', '.conf'); $backup_ext = array('_custom.conf', '.conf');
$dir = $cnf_int->get('ASTETCDIR'); $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(); $zip = new \ZipArchive();
$filename = $dir . "/sccp_instal_backup" . date("Ymd"). ".zip"; $filename = $dir . "/sccp_instal_backup" . date("Ymd"). ".zip";
if ($zip->open($filename, \ZIPARCHIVE::CREATE)) { if ($zip->open($filename, \ZIPARCHIVE::CREATE)) {
@ -814,33 +811,13 @@ function CreateBackUpConfig() {
} }
} }
} }
if (file_exists($fsql)) {
$zip->addFile($fsql);
}
$zip->close(); $zip->close();
} else { } else {
outn("<li>" . _("Error Create BackUp: ") . $filename ."</li>"); outn("<li>" . _("Error Create BackUp: ") . $filename ."</li>");
} }
unlink($fsql);
outn("<li>" . _("Create Config BackUp: ") . $filename ."</li>"); outn("<li>" . _("Create Config BackUp: ") . $filename ."</li>");
} }
function RenameConfig() {
global $amp_conf;
outn("<li>" . _("Move Old Config") . "</li>");
$cnf_int = \FreePBX::Config();
$rename_files = array('sccp_hardware','sccp_extensions');
$rename_ext = array('_custom.conf', '.conf');
$dir = $cnf_int->get('ASTETCDIR');
foreach ($rename_files as $file) {
foreach ($rename_ext as $b_ext) {
if (file_exists($dir . '/'.$file . $b_ext)) {
rename($dir . '/'.$file . $b_ext, $dir . '/'.$file . $b_ext.'.old');
}
}
}
}
function Setup_RealTime() { function Setup_RealTime() {
global $amp_conf; global $amp_conf;
outn("<li>" . _("Pre config RealTime") . "</li>"); outn("<li>" . _("Pre config RealTime") . "</li>");
@ -852,7 +829,7 @@ function Setup_RealTime() {
$def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline'); $def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline');
$def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'],
'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'],
'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock', 'dbcharset'=>'utf8'); 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock','dbcharset'=>'utf8');
$def_bd_sec = 'sccp'; $def_bd_sec = 'sccp';
$dir = $cnf_int->get('ASTETCDIR'); $dir = $cnf_int->get('ASTETCDIR');
@ -929,6 +906,9 @@ if ($sccp_compatible == 0) {
$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_sccpusers(); InstallDB_sccpusers();
InstallDB_Buttons(); InstallDB_Buttons();
InstallDB_sccpsettings(); InstallDB_sccpsettings();

View file

@ -5,6 +5,31 @@
/* !TODO!: This would require the install.php to make a note of all the actions that were skipped and/or performed */ /* !TODO!: This would require the install.php to make a note of all the actions that were skipped and/or performed */
/* !TODO!: Might be a good idea to create a backup of the database before removing anything */ /* !TODO!: Might be a good idea to create a backup of the database before removing anything */
// !TODO!: -TODO-: I remove only that which is related to the Manager, it is in my opinion not a critical configuration information. This information is partially present in other files. // !TODO!: -TODO-: I remove only that which is related to the Manager, it is in my opinion not a critical configuration information. This information is partially present in other files.
/*
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_ext = array('_custom.conf', '.conf');
$dir = $cnf_int->get('ASTETCDIR');
$zip = new \ZipArchive();
$filename = $dir . "/sccp_uninstall_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);
}
}
}
$zip->close();
} else {
outn("<li>" . _("Error Create BackUp: ") . $filename ."</li>");
}
outn("<li>" . _("Create Config BackUp: ") . $filename ."</li>");
}
*/
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
global $db; global $db;