Skip to content

Commit

Permalink
#837 Добавил проверку диска в случае ошибки монтирования
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Dec 27, 2024
1 parent b3fdc43 commit 2d18683
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Core/System/RootFS/sbin/initial_storage_part_four
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ if [ "$resultParted" = "0" ];then
"/sbin/fsck.${type}" -a "${partitionFour}" > /dev/null 2>&1;
fsckResult="$?";
if [ "$fsckResult" != "0" ]; then
echo " - ERROR: check fs on '${partitionFour}' type: '${type}' exit code '$?'"
echo " - ERROR: check fs on '${partitionFour}' type: '${type}' exit code '$fsckResult'"
else
echo " - check completed..."
fi;
else
echo " - ERROR: umount ${partitionFour} exit code $?"
echo " - ERROR: umount ${partitionFour} exit code $mountResult"
fi;
else
echo " - partition №4 on ${dev} not found...";
Expand Down
14 changes: 12 additions & 2 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,6 @@ public static function isStorageDisk(string $device): bool

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;
}
Expand Down Expand Up @@ -698,6 +696,18 @@ public function configure(): void
$mount_point = "/storage/usbdisk{$disk['id']}";
Util::mwMkdir($mount_point);
SystemMessages::sysLogMsg(__METHOD__, "Create mount point: $conf");

$mountPath = Util::which('mount');
$resultMountCode = Processes::mwExec("$mountPath -t $formatFs $str_uid $mount_point", $out);
if($resultMountCode !== 0){
echo("Fail mount $dev whith $str_uid, FS_TYPE - $formatFs...") . PHP_EOL;
echo("Trying check device $dev ...") . PHP_EOL;
passthru("/sbin/fsck.$formatFs -y '$dev'");
echo("Trying mount device $dev ...") . PHP_EOL;
$resultMountCode = Processes::mwExec("$mountPath -t $formatFs $str_uid $mount_point", $out);
echo("Result mount code $resultMountCode ...") . PHP_EOL;
}

}

// Save the configuration to the fstab file
Expand Down

0 comments on commit 2d18683

Please sign in to comment.