From 3290bad7e100fdce57decddbfa25ba2d1df9e27b Mon Sep 17 00:00:00 2001 From: boffart <> Date: Mon, 17 Jun 2024 15:23:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B7=D0=BD=D0=B0=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=BF=D0=B2=D0=BA=D0=B8=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D1=81=D1=81=D0=B0=20=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=90=D0=A2?= =?UTF-8?q?=D0=A1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/System/PBXInstaller.php | 28 +++++++++++++--------------- src/Core/System/Storage.php | 7 +++---- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/Core/System/PBXInstaller.php b/src/Core/System/PBXInstaller.php index e0c189617..163ae1ad6 100644 --- a/src/Core/System/PBXInstaller.php +++ b/src/Core/System/PBXInstaller.php @@ -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', ''); @@ -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'; @@ -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, ''); @@ -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"); } } \ No newline at end of file diff --git a/src/Core/System/Storage.php b/src/Core/System/Storage.php index 71730d51d..571964d78 100644 --- a/src/Core/System/Storage.php +++ b/src/Core/System/Storage.php @@ -572,7 +572,7 @@ public static function selectAndConfigureStorageDisk(bool $automatic=false, bool passthru("exec /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, @@ -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"; // Save the disk settings $storage->saveDiskSettings($data); if (file_exists('/offload/livecd')) { @@ -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); }