Skip to content

Commit

Permalink
#745 Расширил вывод информации в консоль для отладки.
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Jun 17, 2024
1 parent 3290bad commit e9f7427
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
26 changes: 16 additions & 10 deletions src/Core/System/PBXInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,13 @@ private function copyConfiguration():void
Util::mwMkdir('/mnttmp');

$confPartitionName = Storage::getDevPartName("/dev/$this->target_disk", '3');

// Mount the disk with settings.
$mount = Util::which('mount');
Processes::mwExec("$mount -w -o noatime $confPartitionName /mnttmp");

$umount = Util::which('umount');
$resUMount = Processes::mwExec("$umount $confPartitionName");
echo "Umount $confPartitionName: $resUMount ...".PHP_EOL;
$resMount = Processes::mwExec("$mount -w -o noatime $confPartitionName /mnttmp");
echo "Mount $confPartitionName to /mnttmp: $resMount ...".PHP_EOL;
$filename = $this->config->path('database.dbfile');
$result_db_file = '/mnttmp/conf/mikopbx.db';

Expand All @@ -286,8 +288,10 @@ private function copyConfiguration():void
$tables = ['m_Storage', 'm_LanInterfaces'];
file_put_contents($dmpDbFile, '');
foreach ($tables as $table) {
shell_exec("sqlite3 /cf/conf/mikopbx.db '.schema $table' >> $dmpDbFile");
shell_exec("sqlite3 /cf/conf/mikopbx.db '.dump $table' >> $dmpDbFile");
echo "DUMP $table from /cf/conf/mikopbx.db ...".PHP_EOL;
$res = shell_exec("sqlite3 /cf/conf/mikopbx.db '.schema $table' >> $dmpDbFile");
$res .= shell_exec("sqlite3 /cf/conf/mikopbx.db '.dump $table' >> $dmpDbFile");
echo "$res ...".PHP_EOL;
}
// If another language is selected - use another settings file.
$lang = PbxSettings::getValueByKey(PbxSettingsConstants::SSH_LANGUAGE);
Expand All @@ -296,15 +300,17 @@ private function copyConfiguration():void
$filename = $filename_lang;
}
// Replace the settings file.
Processes::mwExec("$cp $filename $result_db_file");
$resCopy = Processes::mwExec("$cp $filename $result_db_file");
echo "Copy $filename to $result_db_file: $resCopy ...".PHP_EOL;
foreach ($tables as $table) {
system("$sqlite3 $result_db_file 'DROP TABLE IF EXISTS $table'");
echo "DROP $table IF EXISTS in $result_db_file ...".PHP_EOL;
$res = shell_exec("$sqlite3 $result_db_file 'DROP TABLE IF EXISTS $table'");
echo "$res ...".PHP_EOL;
}
// Restore settings from backup file.
system("$sqlite3 $result_db_file < $dmpDbFile");
$resSaveSettings = Processes::mwExec("$sqlite3 $result_db_file < $dmpDbFile");
echo "Save settings to $result_db_file. Result: $resSaveSettings ...".PHP_EOL;
unlink($dmpDbFile);

$umount = Util::which('umount');
Processes::mwExec("$umount /mnttmp");
}
}
6 changes: 4 additions & 2 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public static function selectAndConfigureStorageDisk(bool $automatic=false, bool
'filesystemtype' => 'ext4',
'name' => 'Storage №1'
];
echo PHP_EOL ."Disk part: $dev_disk, uid: $uuid";
echo PHP_EOL ."Disk part: $dev_disk, uid: $uuid".PHP_EOL;
// Save the disk settings
$storage->saveDiskSettings($data);
if (file_exists('/offload/livecd')) {
Expand Down Expand Up @@ -729,7 +729,9 @@ public function saveDiskSettings(array $data, string $id = '1'): void
foreach ($data as $key => $value) {
$storage_settings->writeAttribute($key, $value);
}
$storage_settings->save();
if(!$storage_settings->save()){
echo PHP_EOL ."Fail save new storage ID in database...".PHP_EOL;
}
}

/**
Expand Down

0 comments on commit e9f7427

Please sign in to comment.