Optimize OS/release/version detection for faster execution #70
10
evocheck.sh
10
evocheck.sh
|
@ -914,6 +914,7 @@ if is_debian; then
|
||||||
|
|
||||||
# Check if reserved blocks for root is at least 5% on every mounted partitions.
|
# Check if reserved blocks for root is at least 5% on every mounted partitions.
|
||||||
if [ "$IS_TUNE2FS_M5" = 1 ]; then
|
if [ "$IS_TUNE2FS_M5" = 1 ]; then
|
||||||
|
BC_BIN=$(command -v bc)
|
||||||
parts=$(grep -E "ext(3|4)" /proc/mounts | cut -d ' ' -f1 | tr -s '\n' ' ')
|
parts=$(grep -E "ext(3|4)" /proc/mounts | cut -d ' ' -f1 | tr -s '\n' ' ')
|
||||||
for part in $parts; do
|
for part in $parts; do
|
||||||
blockCount=$(dumpe2fs -h "$part" 2>/dev/null | grep -e "Block count:" | grep -Eo "[0-9]+")
|
blockCount=$(dumpe2fs -h "$part" 2>/dev/null | grep -e "Block count:" | grep -Eo "[0-9]+")
|
||||||
|
@ -922,8 +923,13 @@ if is_debian; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
reservedBlockCount=$(dumpe2fs -h "$part" 2>/dev/null | grep -e "Reserved block count:" | grep -Eo "[0-9]+")
|
reservedBlockCount=$(dumpe2fs -h "$part" 2>/dev/null | grep -e "Reserved block count:" | grep -Eo "[0-9]+")
|
||||||
# Use bc to have a rounded percentage
|
if [ -x "$BC_BIN" ]; then
|
||||||
percentage=$(echo "(${reservedBlockCount} * 100 / ${blockCount}) + 1" | bc)
|
# Use bc to have a rounded percentage
|
||||||
|
percentage=$(echo "(${reservedBlockCount} * 100 / ${blockCount}) + 1" | $BC_BIN)
|
||||||
|
else
|
||||||
|
# fallback to python
|
||||||
|
percentage=$(python -c "print(int(round(float(${reservedBlockCount})/${blockCount}*100)))")
|
||||||
|
fi
|
||||||
if [ "$percentage" -lt 5 ]; then
|
if [ "$percentage" -lt 5 ]; then
|
||||||
failed "IS_TUNE2FS_M5" "Partition ${part} has less than 5% reserved blocks (${percentage}%)"
|
failed "IS_TUNE2FS_M5" "Partition ${part} has less than 5% reserved blocks (${percentage}%)"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue