Add toggle to enable/disable fsck check on boot

This commit is contained in:
Taylor Helsper 2021-05-18 00:27:49 -05:00
parent 16f9e3277d
commit 73ef0c52bd
4 changed files with 42 additions and 11 deletions

View File

@ -118,17 +118,19 @@ fi
# Check drive (only if exactly 1 is found)
set +e
if [ $IS_X86 = 0 ]; then
touch /tmp/repairing_drive
for d in /dev/sd*1 /dev/hd*1 /dev/vd*1 /dev/nvme*p1; do
echo "Repairing drive $d ...";
fsck -y $d > /tmp/fsck_results 2>&1
RC=$?
echo "" >> /tmp/fsck_results
echo "Code: $RC" >> /tmp/fsck_results
if [ "$RC" -ne 0 ] && [ "$RC" -ne 8 ] ; then
touch /tmp/fsck_error
fi
done
if [ ! -f /home/bitcoin/.mynode/skip_fsck ]; then
touch /tmp/repairing_drive
for d in /dev/sd*1 /dev/hd*1 /dev/vd*1 /dev/nvme*p1; do
echo "Repairing drive $d ...";
fsck -y $d > /tmp/fsck_results 2>&1
RC=$?
echo "" >> /tmp/fsck_results
echo "Code: $RC" >> /tmp/fsck_results
if [ "$RC" -ne 0 ] && [ "$RC" -ne 8 ] ; then
touch /tmp/fsck_error
fi
done
fi
fi
rm -f /tmp/repairing_drive
set -e

View File

@ -677,6 +677,15 @@ def get_fsck_results():
return "ERROR"
return "ERROR"
def set_skip_fsck(skip):
if skip:
os.system("touch /home/bitcoin/.mynode/skip_fsck")
else:
os.system("rm -f /home/bitcoin/.mynode/skip_fsck")
os.system("sync")
def skip_fsck():
return os.path.isfile("/home/bitcoin/.mynode/skip_fsck")
def has_sd_rw_error():
return os.path.isfile("/tmp/sd_rw_error")

View File

@ -87,6 +87,7 @@ def page_settings():
"upload_rate": upload_rate,
"is_btc_lnd_tor_enabled": is_btc_lnd_tor_enabled(),
"is_aptget_tor_enabled": is_aptget_tor_enabled(),
"skip_fsck": skip_fsck(),
"uptime": uptime,
"date": date,
"local_ip": local_ip,
@ -945,6 +946,17 @@ def toggle_netdata_page():
enable_service("netdata")
return redirect("/settings")
@mynode_settings.route("/settings/toggle-check-external-drive")
def toggle_check_external_drive_page():
check_logged_in()
if skip_fsck():
set_skip_fsck(False)
else:
set_skip_fsck(True)
flash("Check External Drive Updated", category="message")
return redirect("/settings")
@mynode_settings.route("/settings/modify-swap")
def modify_swap_page():
check_logged_in()

View File

@ -942,6 +942,14 @@
<br/>
<a href="/settings/remount-external-drive" class="ui-button ui-widget ui-corner-all settings_button">Remount Drive</a>
<div class="divider"></div>
<div class="settings_block_subheader">Check External Drive</div>
The external drive will be checked for errors automatically on each boot. This can be disabled, but is not recommended.
<br/>
<a href="/settings/toggle-check-external-drive" class="ui-button ui-widget ui-corner-all settings_button">{% if skip_fsck %}Enable{% else %}Disable{% endif %}</a>
<div class="divider"></div>
<div class="settings_block_subheader">Format External Drive</div>