Skip to content

Commit

Permalink
Незначительные прапвки вывода процесса установки АТС.
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Jun 17, 2024
1 parent 9f107aa commit 3290bad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
28 changes: 13 additions & 15 deletions src/Core/System/PBXInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ private function proceedInstallation()
$this->unpackImage();
$this->mountStorage();
$this->copyConfiguration();
$umount = Util::which('umount');
Processes::mwExec("$umount /mnttmp");
echo "done\n";

// Reboot
file_put_contents('/tmp/ejectcd', '');
Expand Down Expand Up @@ -266,17 +263,17 @@ private function mountStorage()
/**
* Copy the configuration to the target disk.
*/
private function copyConfiguration()
private function copyConfiguration():void
{
// Back up the table with disk information.
echo Util::translate("Copying configuration...");
echo Util::translate("Copying configuration...").PHP_EOL;
Util::mwMkdir('/mnttmp');

$confPartitionName = Storage::getDevPartName("/dev/{$this->target_disk}", '3');
$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");
Processes::mwExec("$mount -w -o noatime $confPartitionName /mnttmp");

$filename = $this->config->path('database.dbfile');
$result_db_file = '/mnttmp/conf/mikopbx.db';
Expand All @@ -285,7 +282,6 @@ private function copyConfiguration()
$cp = Util::which('cp');
$sqlite3 = Util::which('sqlite3');
$dmpDbFile = tempnam('/tmp', 'storage');

// Save dump of settings.
$tables = ['m_Storage', 'm_LanInterfaces'];
file_put_contents($dmpDbFile, '');
Expand All @@ -295,18 +291,20 @@ private function copyConfiguration()
}
// If another language is selected - use another settings file.
$lang = PbxSettings::getValueByKey(PbxSettingsConstants::SSH_LANGUAGE);
$filename_lang = "/offload/conf/mikopbx-{$lang}.db";
$filename_lang = "/offload/conf/mikopbx-$lang.db";
if ($lang !== 'en' && file_exists($filename_lang)) {
$filename = $filename_lang;
}

// Replace the settings file.
Processes::mwExec("{$cp} {$filename} {$result_db_file}");
system("{$sqlite3} {$result_db_file} 'DROP TABLE IF EXISTS m_Storage'");
system("{$sqlite3} {$result_db_file} 'DROP TABLE IF EXISTS m_LanInterfaces'");

Processes::mwExec("$cp $filename $result_db_file");
foreach ($tables as $table) {
system("$sqlite3 $result_db_file 'DROP TABLE IF EXISTS $table'");
}
// Restore settings from backup file.
system("{$sqlite3} {$result_db_file} < {$dmpDbFile}");
system("$sqlite3 $result_db_file < $dmpDbFile");
unlink($dmpDbFile);

$umount = Util::which('umount');
Processes::mwExec("$umount /mnttmp");
}
}
7 changes: 3 additions & 4 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,15 @@ public static function selectAndConfigureStorageDisk(bool $automatic=false, bool
passthru("exec </dev/console >/dev/console 2>/dev/console; /sbin/initial_storage_part_four update {$dev_disk}");
}
$partitionName = self::getDevPartName($target_disk_storage, $part);
$uuid = $storage->getUuid($partitionName);
$uuid = self::getUuid($partitionName);
// Create an array of disk data
$data = [
'device' => $dev_disk,
'uniqid' => $uuid,
'filesystemtype' => 'ext4',
'name' => 'Storage №1'
];

echo PHP_EOL ."Disk part: $dev_disk, uid: $uuid";
// Save the disk settings
$storage->saveDiskSettings($data);
if (file_exists('/offload/livecd')) {
Expand Down Expand Up @@ -1879,8 +1879,7 @@ public static function mountDisk(string $dev, string $format, string $dir): bool
Processes::mwExec("{$mountNtfs3gPath} /dev/{$dev} {$dir}", $out);
} else {
// Mount disk using specified file system format and UUID
$storage = new self();
$uid_part = 'UUID=' . $storage->getUuid("/dev/{$dev}") . '';
$uid_part = 'UUID=' . self::getUuid("/dev/{$dev}");
$mountPath = Util::which('mount');
Processes::mwExec("{$mountPath} -t {$format} {$uid_part} {$dir}", $out);
}
Expand Down

0 comments on commit 3290bad

Please sign in to comment.