Skip to content

Commit

Permalink
#837 Правки вывода информации о подключении диска для хранения данных
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Dec 26, 2024
1 parent 8c242a7 commit b3fdc43
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,12 @@ public static function getDevPartName(string $dev, string $part, bool $verbose =
*/
public static function isStorageDisk(string $device): bool
{
$result = false;
// Check if the device path exists
if (!file_exists($device)) {
return $result;
echo("Disk $device not found") . PHP_EOL;
return false;
}

$result = false;
$tmp_dir = '/tmp/mnt_' . time();
Util::mwMkdir($tmp_dir);
$out = [];
Expand All @@ -562,18 +562,21 @@ public static function isStorageDisk(string $device): bool
$storage = new self();
$format = $storage->getFsType($device);
// If the file system type is not available, return false
if ($format === '') {
if (empty($format)) {
echo("For Disk $device ($uid_part), FS_TYPE empty...") . PHP_EOL;
return false;
}
$mount = Util::which('mount');
echo("For Disk $device get $uid_part, FS_TYPE=$format...") . PHP_EOL;
$mount = Util::which('mount');
$umount = Util::which('umount');
$rm = Util::which('rm');
$rm = Util::which('rm');

Processes::mwExec("$mount -t $format $uid_part $tmp_dir", $out);
if (is_dir("$tmp_dir/mikopbx") && trim(implode('', $out)) === '') {
// $out - empty string, no errors
// mikopbx directory exists
$result = true;
echo("Disk $device is storage...") . PHP_EOL;
}

// Check if the storage disk is mounted, and unmount if necessary
Expand Down

0 comments on commit b3fdc43

Please sign in to comment.