mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 09:39:58 -06:00
feat: exFAT support
chore: refactor file sysem check scripts fix: fix some mode bits
This commit is contained in:
@@ -316,10 +316,6 @@ Not much info is printed in the window, but you can verify the operation is runn
|
||||
increasing for the device on the Main page.
|
||||
:end
|
||||
|
||||
:info_reiserfs_cancel_help:
|
||||
**Cancel** will cancel the Check operation in progress.
|
||||
:end
|
||||
|
||||
:info_xfs_check_help:
|
||||
**Check** will run the *xfs_repair* program to check file system integrity on the device.
|
||||
|
||||
@@ -332,15 +328,11 @@ Not much info is printed in the window, but you can verify the operation is runn
|
||||
increasing for the device on the Main page.
|
||||
:end
|
||||
|
||||
:info_xfs_cancel_help:
|
||||
**Cancel** will cancel the Check operation in progress.
|
||||
:end
|
||||
|
||||
:info_ext_check_help:
|
||||
**Check** will run the *e2fsck* program to check file system integrity on the device. Despite its name, *e2fsck* is used
|
||||
to check the whole family of ext2/ext3/ext4 file systems.
|
||||
|
||||
The *Options* field is initialized with *-p* option to automatically fix any file system problems that can be safely fixed
|
||||
For **Fix** the *Options* field is initialized with *-p* option to automatically fix any file system problems that can be safely fixed
|
||||
without intervention. If a problem is discovered which may require additional corrective action, e2fsck will print a
|
||||
description of the problem and then exit.
|
||||
|
||||
@@ -360,8 +352,11 @@ Note: *ntfsfix* will immediately exit if a hibernation file is detected (to prev
|
||||
The *Options* field is initialized with *-d* to clear the volume dirty flag if the volume can be fixed and mounted.
|
||||
:end
|
||||
|
||||
:info_ext_cancel_help:
|
||||
**Cancel** will cancel the Check operation in progress.
|
||||
:info_exfat_check_help:
|
||||
**Check** will run the *fsck.exfat* program to check file system integrity on the device.
|
||||
|
||||
For **Fix** the *Options* field is initialized with *-p* to repair the filesystem without user interaction if it can
|
||||
be done safely.
|
||||
:end
|
||||
|
||||
:info_smart_notifications_help:
|
||||
|
||||
0
emhttp/plugins/dynamix/ArrayOperation.page
Executable file → Normal file
0
emhttp/plugins/dynamix/ArrayOperation.page
Executable file → Normal file
0
emhttp/plugins/dynamix/DashStats.page
Executable file → Normal file
0
emhttp/plugins/dynamix/DashStats.page
Executable file → Normal file
@@ -284,6 +284,12 @@ function selectDiskFsProfileNTFS() {
|
||||
$('#diskFsProfile').val('');
|
||||
setDiskFsWidth(1);
|
||||
}
|
||||
function selectDiskFsProfileEXFAT() {
|
||||
$('#diskFsProfile').empty();
|
||||
$('#diskFsProfile').append($('<option>', {value: '', text:''}));
|
||||
$('#diskFsProfile').val('');
|
||||
setDiskFsWidth(1);
|
||||
}
|
||||
function selectDiskFsProfileBTRFS(slots,init) {
|
||||
$('#diskFsProfile').empty();
|
||||
$('#diskFsProfile').append($('<option>', {value: 'single', text:_('single')}));
|
||||
@@ -415,9 +421,11 @@ function selectDiskFsProfile(init) {
|
||||
selectDiskFsProfileEXT();
|
||||
} else if (fsType.indexOf('ntfs') != -1) {
|
||||
selectDiskFsProfileNTFS();
|
||||
} else if (fsType.indexOf('exfat') != -1) {
|
||||
selectDiskFsProfileEXFAT();
|
||||
}
|
||||
|
||||
if (subpool != '' || fsType == 'auto' || fsType.indexOf('xfs') != -1 || fsType.indexOf('ext') != -1 || fsType.indexOf('ntfs') != -1) {
|
||||
if (subpool != '' || fsType == 'auto' || fsType.indexOf('xfs') != -1 || fsType.indexOf('ext') != -1 || fsType.indexOf('ntfs') != -1 || fsType.indexOf('exfat') != -1) {
|
||||
$('#compression').hide(t);
|
||||
$('#diskCompression').prop('disabled',true);
|
||||
} else {
|
||||
@@ -605,13 +613,13 @@ function zfsExpansion(path) {
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function rfsCheck(path) {
|
||||
$.post('/webGui/include/FileSystemStatus.php',{cmd:'rfs-check',path:path},function(data) {
|
||||
$('#rfs-check').text(data);
|
||||
function reiserfsCheck(path) {
|
||||
$.post('/webGui/include/FileSystemStatus.php',{cmd:'reiserfs-check',path:path},function(data) {
|
||||
$('#reiserfs-check').text(data);
|
||||
if (data.slice(-1)!='\0') {
|
||||
setTimeout(function(){rfsCheck(path);},1000);
|
||||
setTimeout(function(){reiserfsCheck(path);},1000);
|
||||
} else {
|
||||
$.removeCookie('rfs-check-<?=$tag?>');
|
||||
$.removeCookie('reiserfs-check-<?=$tag?>');
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
@@ -653,6 +661,18 @@ function ntfsCheck(path) {
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function exfatCheck(path) {
|
||||
$.post('/webGui/include/FileSystemStatus.php',{cmd:'exfat-check',path:path},function(data) {
|
||||
$('#exfat-check').text(data);
|
||||
if (data.slice(-1)!='\0') {
|
||||
setTimeout(function(){exfatCheck(path);},1000);
|
||||
} else {
|
||||
$.removeCookie('exfat-check-<?=$tag?>');
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function updateMode(form,mode) {
|
||||
$(form).find('input[name="#arg[3]"]').val(mode);
|
||||
}
|
||||
@@ -857,29 +877,36 @@ _(Spin down delay)_:
|
||||
_(File system status)_:
|
||||
: <?=_(_var($disk, 'fsStatus'))?>
|
||||
|
||||
<?if (_var($var, 'fsState') == "Started"):?>
|
||||
<?if ($fsTypeImmutable):?>
|
||||
_(File system type)_:
|
||||
: <?=_(_var($disk, 'fsType'))?>
|
||||
<?else:?>
|
||||
_(File system type)_:
|
||||
: <select id="diskFsType" name="diskFsType.<?=_var($disk, 'idx')?>" onchange="selectDiskFsProfile(false)" <?=disabled_if($fsTypeImmutable)?>>
|
||||
<?=mk_option(_var($disk, 'fsType'), "auto", _('auto'))?>
|
||||
: <select id="diskFsType" name="diskFsType.<?=_var($disk, 'idx')?>" onchange="selectDiskFsProfile(false)">
|
||||
<?echo "<optgroup label='Standard'>"?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "auto", _('Auto'))?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "xfs", _('xfs'))?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "zfs", _('zfs'))?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "btrfs", _('btrfs'))?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "ext4", _('ext4'))?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "ext3", _('ext3'), "disabled")?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "ext2", _('ext2'), "disabled")?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "ntfs", _('ntfs'))?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "reiserfs", _('reiserfs'), "disabled")?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "btrfs", _('btrfs'))?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "zfs", _('zfs'))?>
|
||||
<?echo "</optgroup>"?>
|
||||
<?echo "<optgroup label='Encrypted'>"?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "luks:xfs", _('xfs')." - "._('encrypted'))?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "luks:zfs", _('zfs')." - "._('encrypted'))?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "luks:btrfs", _('btrfs')." - "._('encrypted'))?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "luks:ext4", _('ext4')." - "._('encrypted'))?>
|
||||
<?if (_var($disk,'slots',1) == 1) echo mk_option(_var($disk,'fsType'), "luks:reiserfs", _('reiserfs')." - "._('encrypted'), "disabled")?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "luks:btrfs", _('btrfs')." - "._('encrypted'))?>
|
||||
<?=mk_option(_var($disk, 'fsType'), "luks:zfs", _('zfs')." - "._('encrypted'))?>
|
||||
<?echo "</optgroup>"?>
|
||||
<?if (_var($disk,'slots',1) == 1):?>
|
||||
<?echo "<optgroup label='Limited support'>"?>
|
||||
<?echo mk_option(_var($disk,'fsType'), "ntfs", _('ntfs'))?>
|
||||
<?echo mk_option(_var($disk,'fsType'), "exfat", _('exfat'))?>
|
||||
<?echo mk_option(_var($disk,'fsType'), "reiserfs", _('reiserfs')." ("._('deprecated').")", "disabled")?>
|
||||
<?echo mk_option(_var($disk,'fsType'), "luks:reiserfs", _('reiserfs')." - "._('encrypted')." ("._('deprecated').")", "disabled")?>
|
||||
<?echo "</optgroup>"?>
|
||||
<?endif;?>
|
||||
</select>
|
||||
<span id="reiserfs" class="warning"<?if (!fsType('reiserfs')):?> style="display:none"<?endif;?>><i class="fa fa-warning"></i> _(ReiserFS is deprecated, please use another file system)_!</span>
|
||||
<?endif;?>
|
||||
<span id="reiserfs" class="warning"<?if (!fsType('reiserfs')):?> style="display:none"<?endif;?>><i class="fa fa-warning"></i> _(ReiserFS is deprecated)_!</span>
|
||||
<?endif;?>
|
||||
|
||||
<?if (diskType('Data') || isPool($tag)):?>
|
||||
@@ -1252,7 +1279,7 @@ _(Time of the day)_:
|
||||
_(btrfs check status)_:
|
||||
: <pre id='btrfs-check'><?=implode("\n", $check_status)?></pre>
|
||||
|
||||
<?if ($retval == 0):?>
|
||||
<?if ($retval != 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/btrfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1267,7 +1294,7 @@ _(btrfs check status)_:
|
||||
|
||||
:info_btrfs_check_help:
|
||||
|
||||
<?else:?>
|
||||
<?elseif ($retval == 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/btrfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="cancel">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1435,14 +1462,14 @@ _(Time of the day)_:
|
||||
<i class="title fa fa-shield"></i>_(Check Filesystem Status)_
|
||||
</span>
|
||||
</div>
|
||||
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'rfs-check-<?=$tag?>','/dev/<?=_var($disk, 'deviceSb')?> <?=_var($disk, 'id')?>')">
|
||||
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'reiserfs-check-<?=$tag?>','/dev/<?=_var($disk, 'deviceSb')?> <?=_var($disk, 'id')?>')">
|
||||
<?if (maintenance_mode()):?>
|
||||
<?exec("$docroot/webGui/scripts/reiserfs_check status /dev/"._var($disk,'deviceSb')." "._var($disk,'id'), $check_status, $retval)?>
|
||||
|
||||
_(reiserfsck status)_:
|
||||
: <pre id='rfs-check'><?=implode("\n", $check_status)?></pre>
|
||||
: <pre id='reiserfs-check'><?=implode("\n", $check_status)?></pre>
|
||||
|
||||
<?if ($retval != 0):?>
|
||||
<?if ($retval != 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/reiserfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1451,13 +1478,13 @@ _(reiserfsck status)_:
|
||||
|
||||
: <span class="inline-block">
|
||||
<input type="submit" value="_(Check)_">
|
||||
<input type="text" name="#arg[4]" maxlength="256" value="">
|
||||
<input type="text" name="#arg[4]" maxlength="256" value="--check">
|
||||
<span>_(Options (see Help))_</span>
|
||||
</span>
|
||||
|
||||
:info_reiserfs_check_help:
|
||||
|
||||
<?else:?>
|
||||
<?elseif ($retval == 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/reiserfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="cancel">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1469,7 +1496,7 @@ _(reiserfsck status)_:
|
||||
<span>*_(Running)_*</span>
|
||||
</span>
|
||||
|
||||
:info_reiserfs_cancel_help:
|
||||
:info_check_cancel_help:
|
||||
|
||||
<?endif;?>
|
||||
<?else:?>
|
||||
@@ -1496,7 +1523,7 @@ _(reiserfsck status)_:
|
||||
_(xfs_repair status)_:
|
||||
: <pre id='xfs-check'><?=implode("\n", $check_status)?></pre>
|
||||
|
||||
<?if ($retval == 0 || $retval == 8):?>
|
||||
<?if ($retval == 0 || $retval == 4 || $retval == 8):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/xfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1507,6 +1534,7 @@ _(xfs_repair status)_:
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
<?if ($retval == 0): ?> _(No file system corruption detected)_.<?endif; ?>
|
||||
<?if ($retval == 4): ?> _(File system corruption fixed)_.<?endif; ?>
|
||||
</span>
|
||||
|
||||
:info_xfs_check_help:
|
||||
@@ -1543,21 +1571,6 @@ _(xfs_repair status)_:
|
||||
|
||||
:info_xfs_check_help:
|
||||
|
||||
<?elseif ($retval == 4):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/xfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-n">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
_(File system corruption fixed)_
|
||||
</span>
|
||||
|
||||
:info_xfs_check_help:
|
||||
|
||||
<?elseif ($retval == 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/xfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="cancel">
|
||||
@@ -1569,7 +1582,7 @@ _(xfs_repair status)_:
|
||||
*_(Running)_*
|
||||
</span>
|
||||
|
||||
:info_xfs_cancel_help:
|
||||
:info_check_cancel_help:
|
||||
|
||||
<?endif;?>
|
||||
<?else:?>
|
||||
@@ -1596,7 +1609,7 @@ _(xfs_repair status)_:
|
||||
_(ntfsfix_ status)_:
|
||||
: <pre id='ntfs-check'><?=implode("\n", $check_status)?></pre>
|
||||
|
||||
<?if ($retval == 0 || $retval == 8):?>
|
||||
<?if ($retval != 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ntfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1607,53 +1620,9 @@ _(ntfsfix_ status)_:
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
<?if ($retval == 0): ?> _(No file system corruption detected)_.<?endif; ?>
|
||||
</span>
|
||||
|
||||
:info_ntfs_check_help:
|
||||
|
||||
<?elseif ($retval == 1):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ntfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-e">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Fix)_">
|
||||
<span style="color: red;">_(File system corruption detected)_.</span>
|
||||
</span>
|
||||
|
||||
:info_ntfs_check_help:
|
||||
|
||||
<?elseif ($retval == 2):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ntfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-eL">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Zero Log)_">
|
||||
<span style="color: red;">_(Dirty log detected)_.</span>
|
||||
</span>
|
||||
|
||||
<p>_(Note)_: _(While there is some risk, if it is not possible to first mount the filesystem to clear the log, zeroing it is the only option to try and repair the filesystem, and in most cases it results in little or no data loss)_.</p>
|
||||
|
||||
:info_ntfs_check_help:
|
||||
|
||||
<?elseif ($retval == 4):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ntfs_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-n">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
_(File system corruption fixed)_
|
||||
<?if ($retval == 1): ?> _(Basic repair actions applied)_.<?endif; ?>
|
||||
<?if ($retval == 2): ?> <span style="color: red;">_(Fatal error)_.</span><?endif; ?>
|
||||
<?if ($retval == 4): ?> <span style="color: red;">_(Volume is hibernated)_.</span><?endif; ?>
|
||||
</span>
|
||||
|
||||
:info_ntfs_check_help:
|
||||
@@ -1669,7 +1638,7 @@ _(ntfsfix_ status)_:
|
||||
*_(Running)_*
|
||||
</span>
|
||||
|
||||
:info_ntfs_cancel_help:
|
||||
:info_check_cancel_help:
|
||||
|
||||
<?endif;?>
|
||||
<?else:?>
|
||||
@@ -1696,37 +1665,7 @@ _(ntfsfix_ status)_:
|
||||
_(check status)_:
|
||||
: <pre id='ext-check'><?=implode("\n", $check_status)?></pre>
|
||||
|
||||
<?if ($retval == 0 || $retval == 8):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ext_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-v -p">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
<?if ($retval == 0): ?> _(No file system corruption detected)_.<?endif; ?>
|
||||
</span>
|
||||
|
||||
:info_ext_check_help:
|
||||
|
||||
<?elseif ($retval == 1):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ext_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-v -f -y">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Fix)_">
|
||||
<span style="color: red;">_(File system corruption detected)_.</span>
|
||||
</span>
|
||||
|
||||
:info_ext_check_help:
|
||||
|
||||
<?elseif ($retval == 4):?>
|
||||
<?if ($retval == 0 || $retval == 1 || $retval == 8):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ext_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
@@ -1736,7 +1675,23 @@ _(check status)_:
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
_(File system corruption fixed)_
|
||||
<?if ($retval == 0): ?> _(No file system corruption detected)_.<?endif; ?>
|
||||
<?if ($retval == 1): ?> _(File system corruption fixed)_.<?endif; ?>
|
||||
</span>
|
||||
|
||||
:info_ext_check_help:
|
||||
|
||||
<?elseif ($retval == 4):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/ext_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-v -p">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Fix)_">
|
||||
<span style="color: red;">_(File system corruption detected)_.</span>
|
||||
</span>
|
||||
|
||||
:info_ext_check_help:
|
||||
@@ -1753,7 +1708,78 @@ _(check status)_:
|
||||
*_(Running)_*
|
||||
</span>
|
||||
|
||||
:info_ext_cancel_help:
|
||||
:info_check_cancel_help:
|
||||
|
||||
<?endif;?>
|
||||
<?else:?>
|
||||
|
||||
|
||||
: <span class="inline-block">
|
||||
<input type="submit" value="_(Check)_" disabled>
|
||||
<span>**_(Check)_** _(is only available when array is Started in **Maintenance** mode)_.
|
||||
</span>
|
||||
|
||||
<?endif;?>
|
||||
</form>
|
||||
<?endif;?>
|
||||
|
||||
<?if (fsType('exfat')):?>
|
||||
<div class="title nocontrol">
|
||||
<span class="left">
|
||||
<i class="title fa fa-shield"></i>_(Check Filesystem Status)_
|
||||
</span>
|
||||
</div>
|
||||
<form markdown="1" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareFS(this,'exfat-check-<?=$tag?>','/dev/<?=_var($disk, 'deviceSb')?> <?=_var($disk, 'id')?>')">
|
||||
<?if (maintenance_mode()):?>
|
||||
<?exec("$docroot/webGui/scripts/exfat_check status /dev/"._var($disk,'deviceSb')." "._var($disk,'id'), $check_status, $retval)?>
|
||||
|
||||
_(check status)_:
|
||||
: <pre id='exfat-check'><?=implode("\n", $check_status)?></pre>
|
||||
|
||||
<?if ($retval == 0 || $retval == 1 || $retval == 8):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/exfat_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-v -n">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Check)_">
|
||||
<?if ($retval == 0): ?> _(No file system corruption detected)_.<?endif; ?>
|
||||
<?if ($retval == 1): ?> _(File system corruption fixed)_.<?endif; ?>
|
||||
</span>
|
||||
|
||||
:info_exfat_check_help:
|
||||
|
||||
<?elseif ($retval == 4):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/exfat_check">
|
||||
<input type="hidden" name="#arg[1]" value="start">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
<input type="hidden" name="#arg[4]" value="-v -p">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Fix)_">
|
||||
<span style="color: red;">_(File system corruption detected)_.</span>
|
||||
</span>
|
||||
|
||||
:info_exfat_check_help:
|
||||
|
||||
<?elseif ($retval == 9):?>
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/exfat_check">
|
||||
<input type="hidden" name="#arg[1]" value="cancel">
|
||||
<input type="hidden" name="#arg[2]" value="/dev/<?=_var($disk, 'deviceSb')?>">
|
||||
<input type="hidden" name="#arg[3]" value="<?=_var($disk, 'id')?>">
|
||||
|
||||
|
||||
: <span class="buttons-spaced">
|
||||
<input type="submit" value="_(Cancel)_">
|
||||
*_(Running)_*
|
||||
</span>
|
||||
|
||||
:info_check_cancel_help:
|
||||
|
||||
<?endif;?>
|
||||
<?else:?>
|
||||
@@ -1926,10 +1952,11 @@ $(function() {
|
||||
if ($.cookie('zfs-scrub-<?=$tag?>')) status = zfsScrub($.cookie('zfs-scrub-<?=$tag?>'));
|
||||
if ($.cookie('zfs-resilver-<?=$tag?>')) status = zfsResilver($.cookie('zfs-resilver-<?=$tag?>'));
|
||||
if ($.cookie('zfs-expansion-<?=$tag?>')) status = zfsExpansion($.cookie('zfs-expansion-<?=$tag?>'));
|
||||
if ($.cookie('rfs-check-<?=$tag?>')) status = rfsCheck($.cookie('rfs-check-<?=$tag?>'));
|
||||
if ($.cookie('reiserfs-check-<?=$tag?>')) status = reiserfsCheck($.cookie('reiserfs-check-<?=$tag?>'));
|
||||
if ($.cookie('xfs-check-<?=$tag?>')) status = xfsCheck($.cookie('xfs-check-<?=$tag?>'));
|
||||
if ($.cookie('ntfs-check-<?=$tag?>')) status = ntfsCheck($.cookie('ntfs-check-<?=$tag?>'));
|
||||
if ($.cookie('ext-check-<?=$tag?>')) status = extCheck($.cookie('ext-check-<?=$tag?>'));
|
||||
if ($.cookie('ntfs-check-<?=$tag?>')) status = ntfsCheck($.cookie('ntfs-check-<?=$tag?>'));
|
||||
if ($.cookie('exfat-check-<?=$tag?>')) status = exfatCheck($.cookie('exfat-check-<?=$tag?>'));
|
||||
if (status) {
|
||||
$.post('/webGui/include/FileSystemStatus.php',{cmd:'status',path:'<?=$tag?>'},function(a){
|
||||
var action = a.split(',');
|
||||
|
||||
@@ -36,22 +36,17 @@ case 'zfs-expansion':
|
||||
echo shell_exec("/usr/sbin/zpool status -P $path");
|
||||
break;
|
||||
default:
|
||||
[$dev,$id] = array_pad(explode(' ',$path),2,'');
|
||||
$dir = explode('-',$cmd)[0];
|
||||
$file = "/var/lib/$dir/check.status.$id";
|
||||
if (file_exists($file)) {
|
||||
switch ($cmd) {
|
||||
case 'btrfs-check': $pgrep = 'pgrep --ns $$ -f '."'/scripts/btrfs check .*$dev'"; break;
|
||||
case 'rfs-check': $pgrep = 'pgrep --ns $$ -f '."'/scripts/reiserfsck $dev'"; break;
|
||||
case 'xfs-check': $pgrep = 'pgrep --ns $$ -f '."'/scripts/xfs_repair.*$dev'"; break;
|
||||
case 'ext-check': $pgrep = 'pgrep --ns $$ -f '."'/scripts/ext_check.*$dev'"; break;
|
||||
case 'ntfs-check': $pgrep = 'pgrep --ns $$ -f '."'/scripts/ntfs_check.*$dev'"; break;
|
||||
}
|
||||
echo file_get_contents($file);
|
||||
if (!exec($pgrep)) echo "\0";
|
||||
} else {
|
||||
echo "Not available\0";
|
||||
switch ($cmd) {
|
||||
case 'btrfs-check':
|
||||
case 'xfs-check':
|
||||
case 'ext-check':
|
||||
case 'ntfs-check':
|
||||
case 'exfat-check':
|
||||
case 'reiserfs-check':
|
||||
$fs = explode('-',$cmd)[0];
|
||||
[$dev,$id] = array_pad(explode(' ',$path),2,'');
|
||||
exec("$docroot/webGui/scripts/{$fs}_check status $dev $id", $status, $retval);
|
||||
if ($retval != 9) echo "\0";
|
||||
}
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -4,61 +4,9 @@
|
||||
# btrfs_check cancel <dev> <id>
|
||||
# btrfs_check reset <mountpoint>
|
||||
|
||||
# By default btrfs-check outputs to /var/lib/btrfs
|
||||
mkdir -p /var/lib/btrfs
|
||||
FSCK="/sbin/btrfs check"
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
# Start the btrfs check process in the background and log output
|
||||
/sbin/btrfs check $4 $2 &> /var/lib/btrfs/check.status.$3 &
|
||||
pid=$!
|
||||
echo $pid > /var/lib/btrfs/check.pid.$3
|
||||
exit 0
|
||||
;;
|
||||
'status')
|
||||
# Check if the process is running and set the return value accordingly
|
||||
if [ -f /var/lib/btrfs/check.pid.$3 ]; then
|
||||
cat /var/lib/btrfs/check.status.$3
|
||||
pid=$(cat /var/lib/btrfs/check.pid.$3)
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
# Process is running
|
||||
exit 9
|
||||
else
|
||||
if [ -f /var/lib/btrfs/check.status.$3 ]; then
|
||||
rm -f /var/lib/btrfs/check.pid.$3
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ -f /var/lib/btrfs/check.status.$3 ]; then
|
||||
cat /var/lib/btrfs/check.status.$3
|
||||
else
|
||||
echo "Not available"
|
||||
fi
|
||||
fi
|
||||
[[ $1 == reset ]] && exec /sbin/btrfs device stats -z "$2"
|
||||
|
||||
exit 0
|
||||
;;
|
||||
'cancel')
|
||||
# Cancel the btrfs check process
|
||||
if [ -f /var/lib/btrfs/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/btrfs/check.pid.$3)
|
||||
kill $pid
|
||||
while kill -0 $pid 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
echo -e "\nCancelled" >> /var/lib/btrfs/check.status.$3
|
||||
rm -f /var/lib/btrfs/check.pid.$3
|
||||
else
|
||||
echo "No process to cancel"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
;;
|
||||
'reset')
|
||||
exec /sbin/btrfs device stats -z $2
|
||||
;;
|
||||
*)
|
||||
echo "Invalid command"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/check.source"
|
||||
|
||||
95
emhttp/plugins/dynamix/scripts/check.source
Normal file
95
emhttp/plugins/dynamix/scripts/check.source
Normal file
@@ -0,0 +1,95 @@
|
||||
# source this file in "xxx_check" scripts
|
||||
# variable FSCK should be set to the file sysem check program
|
||||
|
||||
# Exit codes:
|
||||
# 0 - No corruption detected or process not found.
|
||||
# N - refer to individual file system check programs
|
||||
# 8 - No check has been run yet.
|
||||
# 9 - Process is still running.
|
||||
|
||||
OUTDIR=/var/lib/check
|
||||
mkdir -p $OUTDIR
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
# Start the process in the background and log output
|
||||
rm -f $OUTDIR/check.status.$3
|
||||
( $FSCK $4 $2 &> $OUTDIR/check.status.$3 ; echo $? > $OUTDIR/check.status.$3.exit )&
|
||||
pid=$!
|
||||
echo $pid > $OUTDIR/check.pid.$3
|
||||
exit 0
|
||||
;;
|
||||
|
||||
'status')
|
||||
# Check if the process is still running
|
||||
if [ -f $OUTDIR/check.pid.$3 ]; then
|
||||
pid=$(cat $OUTDIR/check.pid.$3)
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
# Process is running, return status and exit code 9
|
||||
cat $OUTDIR/check.status.$3
|
||||
exit 9
|
||||
else
|
||||
# Process is not running, read the exit status if available
|
||||
if [ -f $OUTDIR/check.status.$3.exit ]; then
|
||||
exit_status=$(cat $OUTDIR/check.status.$3.exit)
|
||||
cat $OUTDIR/check.status.$3
|
||||
rm -f $OUTDIR/check.pid.$3
|
||||
if [[ $exit_status -eq 0 || $exit_status -eq 1 || $exit_status -eq 2 || $exit_status -eq 4 ]]; then
|
||||
exit $exit_status
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
# Exit status file does not exist, but return status file if available
|
||||
if [ -f $OUTDIR/check.status.$3 ]; then
|
||||
cat $OUTDIR/check.status.$3
|
||||
fi
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# No PID file found, check for existing status
|
||||
if [ -f $OUTDIR/check.status.$3 ]; then
|
||||
cat $OUTDIR/check.status.$3
|
||||
# If no exit status file, assume process completed successfully
|
||||
if [ -f $OUTDIR/check.status.$3.exit ]; then
|
||||
exit_status=$(cat $OUTDIR/check.status.$3.exit)
|
||||
if [[ $exit_status -eq 0 || $exit_status -eq 1 || $exit_status -eq 2 || $exit_status -eq 4 ]]; then
|
||||
exit $exit_status
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
exit 8
|
||||
fi
|
||||
else
|
||||
# No status file found
|
||||
echo "Not available"
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
'cancel')
|
||||
# Cancel the ntfsfix process
|
||||
if [ -f $OUTDIR/check.pid.$3 ]; then
|
||||
pid=$(cat $OUTDIR/check.pid.$3)
|
||||
kill $pid
|
||||
while kill -0 $pid 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
echo -e "\nCancelled" >> $OUTDIR/check.status.$3
|
||||
rm -f $OUTDIR/check.pid.$3
|
||||
else
|
||||
echo "No process to cancel"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
# Handle invalid commands
|
||||
echo "Invalid command"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
9
emhttp/plugins/dynamix/scripts/exfat_check
Executable file
9
emhttp/plugins/dynamix/scripts/exfat_check
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
# exfat_check start <dev> <id> <options>
|
||||
# exfat_check status <dev> <id>
|
||||
# exfat_check cancel <dev> <id>
|
||||
|
||||
FSCK="/sbin/fsck.exfat"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/check.source"
|
||||
@@ -3,94 +3,7 @@
|
||||
# ext_check status <dev> <id>
|
||||
# ext_check cancel <dev> <id>
|
||||
|
||||
# Exit codes:
|
||||
# 0 - No corruption detected or process not found.
|
||||
# 1 - Corruption detected.
|
||||
# 4 - File system corruption fixed.
|
||||
# 8 - No check has been run yet.
|
||||
# 9 - Process is still running.
|
||||
FSCK="/sbin/e2fsck"
|
||||
|
||||
# Using /var/lib because that's where btrfs puts status
|
||||
mkdir -p /var/lib/ext
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
# Start the e2fsck process in the background and log output
|
||||
rm -f /var/lib/ext/check.status.$3
|
||||
{
|
||||
/sbin/e2fsck $4 $2 &> /var/lib/ext/check.status.$3
|
||||
echo $? > /var/lib/ext/check.status.$3.exit
|
||||
} > /dev/null 2>&1 &
|
||||
echo $! > /var/lib/ext/check.pid.$3
|
||||
exit 0
|
||||
;;
|
||||
|
||||
'status')
|
||||
# Check if the process is still running
|
||||
if [ -f /var/lib/ext/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/ext/check.pid.$3)
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
# Process is running, return status and exit code 9
|
||||
cat /var/lib/ext/check.status.$3
|
||||
exit 9
|
||||
else
|
||||
# Process is not running, read the exit status if available
|
||||
if [ -f /var/lib/ext/check.status.$3.exit ]; then
|
||||
exit_status=$(cat /var/lib/ext/check.status.$3.exit)
|
||||
cat /var/lib/ext/check.status.$3
|
||||
rm -f /var/lib/ext/check.pid.$3
|
||||
(( exit_status & 1 )) && exit 4
|
||||
(( exit_status & 4 )) && exit 1
|
||||
exit 0
|
||||
else
|
||||
# Exit status file does not exist, but return status file if available
|
||||
if [ -f /var/lib/ext/check.status.$3 ]; then
|
||||
cat /var/lib/ext/check.status.$3
|
||||
fi
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# No PID file found, check for existing status
|
||||
if [ -f /var/lib/ext/check.status.$3 ]; then
|
||||
cat /var/lib/ext/check.status.$3
|
||||
# If no exit status file, assume process completed successfully
|
||||
if [ -f /var/lib/ext/check.status.$3.exit ]; then
|
||||
exit_status=$(cat /var/lib/ext/check.status.$3.exit)
|
||||
(( exit_status & 1 )) && exit 4
|
||||
(( exit_status & 4 )) && exit 1
|
||||
exit 0
|
||||
else
|
||||
exit 8
|
||||
fi
|
||||
else
|
||||
# No status file found
|
||||
echo "Not available"
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
'cancel')
|
||||
# Cancel the e2fsck process
|
||||
if [ -f /var/lib/ext/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/ext/check.pid.$3)
|
||||
kill $pid
|
||||
while kill -0 $pid 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
echo -e "\nCancelled" >> /var/lib/ext/check.status.$3
|
||||
rm -f /var/lib/ext/check.pid.$3
|
||||
else
|
||||
echo "No process to cancel"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
# Handle invalid commands
|
||||
echo "Invalid command"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/check.source"
|
||||
|
||||
@@ -3,94 +3,7 @@
|
||||
# ntfs_check status <dev> <id>
|
||||
# ntfs_check cancel <dev> <id>
|
||||
|
||||
# Exit codes:
|
||||
# 0 - No corruption detected or process not found.
|
||||
# 1 - Corruption detected.
|
||||
# 4 - File system corruption fixed.
|
||||
# 8 - No check has been run yet.
|
||||
# 9 - Process is still running.
|
||||
FSCK="/bin/ntfsfix"
|
||||
|
||||
# Using /var/lib because that's where btrfs puts status
|
||||
mkdir -p /var/lib/ntfs
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
# Start the ntfsfix process in the background and log output
|
||||
rm -f /var/lib/ntfs/check.status.$3
|
||||
{
|
||||
/bin/ntfsfix $4 $2 &> /var/lib/ntfs/check.status.$3
|
||||
echo $? > /var/lib/ntfs/check.status.$3.exit
|
||||
} > /dev/null 2>&1 &
|
||||
echo $! > /var/lib/ntfs/check.pid.$3
|
||||
exit 0
|
||||
;;
|
||||
|
||||
'status')
|
||||
# Check if the process is still running
|
||||
if [ -f /var/lib/ntfs/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/ntfs/check.pid.$3)
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
# Process is running, return status and exit code 9
|
||||
cat /var/lib/ntfs/check.status.$3
|
||||
exit 9
|
||||
else
|
||||
# Process is not running, read the exit status if available
|
||||
if [ -f /var/lib/ntfs/check.status.$3.exit ]; then
|
||||
exit_status=$(cat /var/lib/ntfs/check.status.$3.exit)
|
||||
cat /var/lib/ntfs/check.status.$3
|
||||
rm -f /var/lib/ntfs/check.pid.$3
|
||||
(( exit_status & 1 )) && exit 4
|
||||
(( exit_status & 6 )) && exit 1
|
||||
exit 0
|
||||
else
|
||||
# Exit status file does not exist, but return status file if available
|
||||
if [ -f /var/lib/ntfs/check.status.$3 ]; then
|
||||
cat /var/lib/ntfs/check.status.$3
|
||||
fi
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# No PID file found, check for existing status
|
||||
if [ -f /var/lib/ntfs/check.status.$3 ]; then
|
||||
cat /var/lib/ntfs/check.status.$3
|
||||
# If no exit status file, assume process completed successfully
|
||||
if [ -f /var/lib/ntfs/check.status.$3.exit ]; then
|
||||
exit_status=$(cat /var/lib/ntfs/check.status.$3.exit)
|
||||
(( exit_status & 1 )) && exit 4
|
||||
(( exit_status & 4 )) && exit 1
|
||||
exit 0
|
||||
else
|
||||
exit 8
|
||||
fi
|
||||
else
|
||||
# No status file found
|
||||
echo "Not available"
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
'cancel')
|
||||
# Cancel the ntfsfix process
|
||||
if [ -f /var/lib/ntfs/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/ntfs/check.pid.$3)
|
||||
kill $pid
|
||||
while kill -0 $pid 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
echo -e "\nCancelled" >> /var/lib/ntfs/check.status.$3
|
||||
rm -f /var/lib/ntfs/check.pid.$3
|
||||
else
|
||||
echo "No process to cancel"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
# Handle invalid commands
|
||||
echo "Invalid command"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/check.source"
|
||||
|
||||
@@ -3,23 +3,7 @@
|
||||
# reiserfs_check status <dev> <id>
|
||||
# reiserfs_check cancel <dev>
|
||||
|
||||
# using /var/lib because that's where btrfs puts status
|
||||
mkdir -p /var/lib/reiserfs
|
||||
case "$1" in
|
||||
'start')
|
||||
# using /var/lib because that's where btrfs puts status
|
||||
exec /sbin/reiserfsck $2 --yes --quiet $4 &> /var/lib/reiserfs/check.status.$3 &
|
||||
;;
|
||||
'status')
|
||||
if [ -f /var/lib/reiserfs/check.status.$3 ]; then
|
||||
cat /var/lib/reiserfs/check.status.$3
|
||||
else
|
||||
echo "Not available"
|
||||
fi;
|
||||
pgrep --ns $$ -f "/sbin/reiserfsck $2" >/dev/null
|
||||
;;
|
||||
'cancel')
|
||||
pkill --ns $$ -f "/sbin/reiserfsck $2"
|
||||
echo "Cancelled" >> /var/lib/reiserfs/check.status.$3
|
||||
;;
|
||||
esac
|
||||
FSCK="/sbin/reiserfsck --yes --quiet"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/check.source"
|
||||
|
||||
@@ -4,96 +4,7 @@
|
||||
# xfs_check cancel <dev>
|
||||
# xfs_check zero_log <dev>
|
||||
|
||||
# Exit codes:
|
||||
# 0 - No corruption detected or process not found.
|
||||
# 1 - Corruption detected.
|
||||
# 2 - Dirty log.
|
||||
# 4 - File system corruption fixed.
|
||||
# 8 - No check has been run yet.
|
||||
# 9 - Process is still running.
|
||||
FSCK="/sbin/xfs_repair"
|
||||
|
||||
# Using /var/lib because that's where btrfs puts status
|
||||
mkdir -p /var/lib/xfs
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
# Start the xfs_repair process in the background and log output
|
||||
rm -f /var/lib/xfs/check.status.$3
|
||||
{
|
||||
/sbin/xfs_repair $4 $2 &> /var/lib/xfs/check.status.$3
|
||||
echo $? > /var/lib/xfs/check.status.$3.exit
|
||||
} > /dev/null 2>&1 &
|
||||
echo $! > /var/lib/xfs/check.pid.$3
|
||||
exit 0
|
||||
;;
|
||||
'status')
|
||||
# Check if the process is still running
|
||||
if [ -f /var/lib/xfs/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/xfs/check.pid.$3)
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
# Process is running, return status and exit code 9
|
||||
cat /var/lib/xfs/check.status.$3
|
||||
exit 9
|
||||
else
|
||||
# Process is not running, read the exit status if available
|
||||
if [ -f /var/lib/xfs/check.status.$3.exit ]; then
|
||||
exit_status=$(cat /var/lib/xfs/check.status.$3.exit)
|
||||
cat /var/lib/xfs/check.status.$3
|
||||
rm -f /var/lib/xfs/check.pid.$3
|
||||
if [[ $exit_status -eq 0 || $exit_status -eq 1 || $exit_status -eq 2 || $exit_status -eq 4 ]]; then
|
||||
exit $exit_status
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
# Exit status file does not exist, but return status file if available
|
||||
if [ -f /var/lib/xfs/check.status.$3 ]; then
|
||||
cat /var/lib/xfs/check.status.$3
|
||||
fi
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# No PID file found, check for existing status
|
||||
if [ -f /var/lib/xfs/check.status.$3 ]; then
|
||||
cat /var/lib/xfs/check.status.$3
|
||||
# If no exit status file, assume process completed successfully
|
||||
if [ -f /var/lib/xfs/check.status.$3.exit ]; then
|
||||
exit_status=$(cat /var/lib/xfs/check.status.$3.exit)
|
||||
if [[ $exit_status -eq 0 || $exit_status -eq 1 || $exit_status -eq 2 || $exit_status -eq 4 ]]; then
|
||||
exit $exit_status
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
exit 8
|
||||
fi
|
||||
else
|
||||
# No status file found
|
||||
echo "Not available"
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
'cancel')
|
||||
# Cancel the xfs_repair process
|
||||
if [ -f /var/lib/xfs/check.pid.$3 ]; then
|
||||
pid=$(cat /var/lib/xfs/check.pid.$3)
|
||||
kill $pid
|
||||
while kill -0 $pid 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
echo -e "\nCancelled" >> /var/lib/xfs/check.status.$3
|
||||
rm -f /var/lib/xfs/check.pid.$3
|
||||
else
|
||||
echo "No process to cancel"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
# Handle invalid commands
|
||||
echo "Invalid command"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/check.source"
|
||||
|
||||
Reference in New Issue
Block a user