mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
Merge pull request #3888 from stefansaraev/fsck
init: fsck -y when automatic repair fails
This commit is contained in:
commit
7d0733d24f
@ -403,28 +403,62 @@
|
|||||||
/bin/busybox reboot
|
/bin/busybox reboot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
force_fsck() {
|
||||||
|
echo "Filesystem corruption has been detected"
|
||||||
|
echo "To prevent an automatic repair attempt continuing"
|
||||||
|
echo "press any key or power off your system within the next 120 seconds"
|
||||||
|
echo ""
|
||||||
|
read -t120 -n1
|
||||||
|
# The exit status is 0 if input is available
|
||||||
|
# The exit status is greater than 128 if the timeout is exceeded
|
||||||
|
if [ "$?" -ne "0" -o "$?" -gt "128" ] ; then
|
||||||
|
echo "repairing filesystem.."
|
||||||
|
echo ""
|
||||||
|
/sbin/fsck -T -M -y $RUN_FSCK_DISKS
|
||||||
|
FSCK_RET="$?"
|
||||||
|
if [ "$(( $FSCK_RET & 8 ))" = 8 ] ; then
|
||||||
|
# fubar
|
||||||
|
echo "Forced fsck failed. Your system is broken beyond repair"
|
||||||
|
echo "Please re-install OpenELEC"
|
||||||
|
echo ""
|
||||||
|
echo "Press enter to shutdown now"
|
||||||
|
echo ""
|
||||||
|
read fubar
|
||||||
|
poweroff
|
||||||
|
fi
|
||||||
|
do_reboot
|
||||||
|
else
|
||||||
|
echo "shutting down..."
|
||||||
|
sleep 5
|
||||||
|
sync
|
||||||
|
poweroff
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
check_disks() {
|
check_disks() {
|
||||||
if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then
|
if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then
|
||||||
progress "Checking disk(s): $RUN_FSCK_DISKS"
|
progress "Checking disk(s): $RUN_FSCK_DISKS"
|
||||||
/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1
|
/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1
|
||||||
FSCK_RET="$?"
|
FSCK_RET="$?"
|
||||||
|
|
||||||
case "$FSCK_RET" in
|
# FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked.
|
||||||
0) # no errors found
|
if [ "$(( $FSCK_RET & 8 ))" = 8 ] ; then
|
||||||
progress "no filesystem errors found, continuing..."
|
# operational error
|
||||||
;;
|
force_fsck
|
||||||
1) # filesystem errors corrected
|
elif [ "$(( $FSCK_RET & 4 ))" = 4 ] ; then
|
||||||
progress "filesystem errors corrected , continuing..."
|
# errors left
|
||||||
;;
|
force_fsck
|
||||||
2) # reboot needed
|
elif [ "$(( $FSCK_RET & 2 ))" = 2 ] ; then
|
||||||
|
# reboot needed
|
||||||
echo "filesystem repaired, reboot needed..."
|
echo "filesystem repaired, reboot needed..."
|
||||||
do_reboot
|
do_reboot
|
||||||
;;
|
elif [ "$(( $FSCK_RET & 1 ))" = 1 ] ; then
|
||||||
4) # errors left
|
# filesystem errors corrected
|
||||||
error "could not repair filesystem, dropping to debug shell, try to run 'fsck' manually"
|
progress "filesystem errors corrected , continuing..."
|
||||||
do_reboot
|
elif [ "$(( $FSCK_RET & 0 ))" = 0 ] ; then
|
||||||
;;
|
# no errors found
|
||||||
esac
|
progress "no filesystem errors found, continuing..."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user