Skip to content

Commit

Permalink
Merge pull request #375 from mikopbx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
boffart authored Jul 22, 2022
2 parents a7d67b7 + e12c0a7 commit b80ba9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
23 changes: 13 additions & 10 deletions src/Core/Rc/connect.storage
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $fp = fopen('php://stdin', 'rb');
$storage = new Storage();

if(Storage::isStorageDiskMounted()){
echo "\n ".Util::translate('Storage disk is already mounted...')." \n\n";
sleep(2);
echo "\n ".Util::translate('Storage disk is already mounted...')." \n\n";
sleep(2);
return 0;
}

Expand All @@ -57,12 +57,12 @@ foreach ($all_hdd as $disk) {

if($isMountedSysDisk){
$system_disk = $disk['id'];
$additional.= "\033[31;1m [SYSTEM]\033[0m";
}elseif($isLiveCd){
$additional.= "\033[31;1m [SYSTEM]\033[0m";
}elseif($isLiveCd){
$system_disk = $disk['id'];
$additional.= "\033[31;1m [SYSTEM]\033[0m";
}elseif ($disk['mounted']){
continue;
}elseif ($disk['mounted']){
continue;
}

if($selected_disk['size'] === 0 || $disk['size'] > $selected_disk['size'] ){
Expand All @@ -72,7 +72,7 @@ foreach ($all_hdd as $disk) {
$part = $disk['sys_disk']?'4':'1';
$devName = Storage::getDevPartName($disk['id'], $part);
$devFour = '/dev/'.$devName;
if(Storage::isStorageDisk($devFour)){
if(Storage::isStorageDisk($devFour)){
$additional.= "\033[33;1m [STORAGE] \033[0m";
}

Expand Down Expand Up @@ -128,14 +128,17 @@ $partName = Storage::getDevPartName($target_disk_storage, $part);
$part_disk = "/dev/$partName";
if($part === '1' && !Storage::isStorageDisk($part_disk)){
$storage->formatDiskLocal($dev_disk);
$partName = Storage::getDevPartName($target_disk_storage, $part);
$part_disk = "/dev/$partName";
}
$uniqId = $storage->getUuid($part_disk);

$data=[
'device' => $dev_disk,
'uniqid' => $uniqId,
'uniqid' => $storage->getUuid($part_disk),
'filesystemtype' => 'ext4',
'name' => 'Storage №1'
];

$storage->saveDiskSettings($data);
if(file_exists('/offload/livecd')) {
// Запуск АТС не требуется, это установка станции в режиме LiveCD.
Expand Down Expand Up @@ -176,4 +179,4 @@ if($success === true){
}

sleep(3);
fclose($STDERR);
fclose($STDERR);
26 changes: 7 additions & 19 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1436,33 +1436,21 @@ public function getStorageFreeSpaceMb(): int
/**
* Сохраняем новые данные диска.
*
* @param $data
* @param string $id
* @param array $data
* @param string $id
*/
public function saveDiskSettings($data, $id = '1'): void
public function saveDiskSettings(array $data, string $id = '1'): void
{
if (!is_array($data)) {
return;
}
$disk_data = $this->getDiskSettings($id);
if (count($disk_data) === 0) {
$uniqid = strtoupper('STORAGE-DISK-' . md5(time()));
$storage_settings = new StorageModel();
foreach ($data as $key => $val) {
$storage_settings->writeAttribute($key, $val);
}
$storage_settings->writeAttribute('uniqid', $uniqid);
$storage_settings->save();
} else {
$storage_settings = StorageModel::findFirst("id = '$id'");
if ($storage_settings === null) {
return;
}
foreach ($data as $key => $value) {
$storage_settings->writeAttribute($key, $value);
}
$storage_settings->save();
}
foreach ($data as $key => $value) {
$storage_settings->writeAttribute($key, $value);
}
$storage_settings->save();
}

/**
Expand Down

0 comments on commit b80ba9e

Please sign in to comment.