Run fsck on each boot and save results

This commit is contained in:
Taylor Helsper 2019-12-11 19:34:34 -06:00
parent 9ffee5af01
commit b6635fd3f7
6 changed files with 31 additions and 36 deletions

View File

@ -41,14 +41,17 @@ if [ $IS_RASPI -eq 1 ] || [ $IS_ROCKPRO64 -eq 1 ]; then
fi fi
umount /mnt/hdd || true umount /mnt/hdd || true
# Check for drive-repair # Check drive
if [ -f /home/bitcoin/.mynode/check_drive ]; then set +e
for d in /dev/sd*1; do for d in /dev/sd*1; do
echo "Repairing drive $d ..."; echo "Repairing drive $d ...";
fsck -y $d RC=$(fsck -y $d > /tmp/fsck_results 2>&1)
done if [ $RC -ne 0 ]; then
rm /home/bitcoin/.mynode/check_drive touch /tmp/fsck_error
fi fi
done
set -e
# Mount HDD (format if necessary) # Mount HDD (format if necessary)
while [ ! -f /mnt/hdd/.mynode ] while [ ! -f /mnt/hdd/.mynode ]

View File

@ -120,6 +120,15 @@ def delete_product_key_error():
os.system("rm -rf /home/bitcoin/.mynode/.product_key_error") os.system("rm -rf /home/bitcoin/.mynode/.product_key_error")
os.system("rm -rf /mnt/hdd/mynode/settings/.product_key_error") os.system("rm -rf /mnt/hdd/mynode/settings/.product_key_error")
def has_fsck_error():
return os.path.isfile("/tmp/fsck_error")
def get_fsck_results():
try:
with open("/tmp/fsck_results", "r") as f:
return f.read()
except:
return "ERROR"
return "ERROR"
def get_local_ip(): def get_local_ip():
local_ip = "unknown" local_ip = "unknown"

View File

@ -369,6 +369,8 @@ def index():
"vpn_enabled": is_vpn_enabled(), "vpn_enabled": is_vpn_enabled(),
"product_key_skipped": pk_skipped, "product_key_skipped": pk_skipped,
"product_key_error": pk_error, "product_key_error": pk_error,
"fsck_error": has_fsck_error(),
"fsck_results": get_fsck_results(),
"drive_usage": get_drive_usage(), "drive_usage": get_drive_usage(),
"cpu_usage": get_cpu_usage(), "cpu_usage": get_cpu_usage(),
"ram_usage": get_ram_usage(), "ram_usage": get_ram_usage(),

View File

@ -385,27 +385,6 @@ def download_logs_page():
return send_from_directory(directory="/tmp/", filename="mynode_logs.tar.gz") return send_from_directory(directory="/tmp/", filename="mynode_logs.tar.gz")
@mynode_settings.route("/settings/repair-drive")
def repair_drive_page():
check_logged_in()
# Touch files to trigger re-checking drive
os.system("touch /home/bitcoin/.mynode/check_drive")
os.system("sync")
# Trigger reboot
t = Timer(1.0, reboot_device)
t.start()
# Wait until device is restarted
templateData = {
"title": "myNode Reboot",
"header_text": "Restarting",
"subheader_text": "This will take several minutes...",
"ui_settings": read_ui_settings()
}
return render_template('reboot.html', **templateData)
@mynode_settings.route("/settings/regen-https-certs") @mynode_settings.route("/settings/regen-https-certs")
def regen_https_certs_page(): def regen_https_certs_page():
check_logged_in() check_logged_in()

View File

@ -133,6 +133,15 @@
{% include 'includes/message_display.html' %} {% include 'includes/message_display.html' %}
{% if fsck_error %}
<div class="main_page_error_block">
<center>
<p>There may be an error with the filesystem on your drive.</p>
<p>{{ fsck_results }}</p>
</center>
</div>
{% endif %}
{% if not has_changed_password %} {% if not has_changed_password %}
<div class="upgrade_ad_main_page"> <div class="upgrade_ad_main_page">
<p style="text-align: center;"><b>Warning!</b><br/>You appear to be using the default password! You should change it to something else on the <a href="/settings">settings</a> page.</p> <p style="text-align: center;"><b>Warning!</b><br/>You appear to be using the default password! You should change it to something else on the <a href="/settings">settings</a> page.</p>

View File

@ -617,13 +617,6 @@
<div class="divider"></div> <div class="divider"></div>
<div class="settings_block_subheader">Repair Drive</div>
This will attempt to repair and block errors on your external drive. Please make a backup before running. This will reboot the device.
<br/>
<a href="/settings/repair-drive" class="ui-button ui-widget ui-corner-all settings_button">Repair Drive</a>
<div class="divider"></div>
<div class="settings_block_subheader">Factory Reset</div> <div class="settings_block_subheader">Factory Reset</div>
This will factory reset your mynode and all storage will be completely reset. Make sure you have backed up all your keys and wallets! This will factory reset your mynode and all storage will be completely reset. Make sure you have backed up all your keys and wallets!
<br/> <br/>