diff --git a/rootfs/standard/usr/bin/mount_drive.tcl b/rootfs/standard/usr/bin/mount_drive.tcl index 564fe5e0..db56b8ec 100755 --- a/rootfs/standard/usr/bin/mount_drive.tcl +++ b/rootfs/standard/usr/bin/mount_drive.tcl @@ -20,12 +20,16 @@ proc checkPartitionForExistingMyNodeFs {partition} { proc checkPartitionsForExistingMyNodeFs {partitionsName} { upvar $partitionsName partitions runCommand mkdir -p /mnt/hdd + + # Check if we are skipping the check (to reformat drive) + if { [file exists /home/bitcoin/.mynode/force_format_prompt] } { + return 0 + } + + # Check each partition foreach partition $partitions { if [checkPartitionForExistingMyNodeFs $partition] { - # Remove this partition from the list so we don't try to - # use it as the config drive later on. - set partitions [lsearch -all -inline -not -exact $partitions $partition] - + # set partitions [lsearch -all -inline -not -exact $partitions $partition] return 1 } } diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index 4c9840b5..23978a15 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -59,6 +59,9 @@ def is_shutting_down(): return os.path.isfile("/tmp/shutting_down") def factory_reset(): + # Try and make sure drive is r/w + os.system("mount -o remount,rw /mnt/hdd") + # Reset subsystems that have local data delete_quicksync_data() diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 9e7e1c59..276bfabc 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -412,6 +412,25 @@ def reboot_device_page(): } return render_template('reboot.html', **templateData) +@mynode_settings.route("/settings/reboot-device-no-format") +def reboot_device_no_format_page(): + check_logged_in() + + os.system("rm -f /home/bitcoin/.mynode/force_format_prompt") + + # 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/shutdown-device") def shutdown_device_page(): check_logged_in() @@ -491,6 +510,33 @@ def reset_firewall_page(): flash("Firewall Reset", category="message") return redirect("/settings") +@mynode_settings.route("/settings/remount-external-drive") +def remount_external_drive_page(): + os.system("mount -o remount,rw /mnt/hdd") + flash("Remounted External Drive", category="message") + return redirect("/settings") + +@mynode_settings.route("/settings/format-external-drive", methods=['POST']) +def format_external_drive_page(): + check_logged_in() + p = pam.pam() + pw = request.form.get('password_format_external_drive') + if pw == None or p.authenticate("admin", pw) == False: + flash("Invalid Password", category="error") + return redirect(url_for(".page_settings")) + else: + check_and_mark_reboot_action("format_external_drive") + + os.system("touch /home/bitcoin/.mynode/force_format_prompt") + + templateData = { + "title": "myNode", + "header_text": "Rebooting", + "subheader_text": "This will take several minutes...", + "ui_settings": read_ui_settings() + } + return render_template('reboot.html', **templateData) + @mynode_settings.route("/settings/factory-reset", methods=['POST']) def factory_reset_page(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/templates/confirm_drive_format.html b/rootfs/standard/var/www/mynode/templates/confirm_drive_format.html index 08213e0d..eb4bca9e 100644 --- a/rootfs/standard/var/www/mynode/templates/confirm_drive_format.html +++ b/rootfs/standard/var/www/mynode/templates/confirm_drive_format.html @@ -11,7 +11,7 @@ window.location.href="/?format=1" }); $("#reboot-device").on("click", function() { - window.location.href="/settings/reboot-device" + window.location.href="/settings/reboot-device-no-format" }); }); diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 71094eec..47a353fc 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -162,7 +162,6 @@ $("#factory_reset_form").submit(); factory_reset_dialog.dialog( "close" ); } - factory_reset_dialog = $( "#factory-reset-dialog" ).dialog({ autoOpen: false, resizable: false, @@ -180,11 +179,35 @@ $("#password_factory_reset").val("") } }); - $("#factory-reset").on("click", function() { factory_reset_dialog.dialog( "open" ); }); + function formatExternalDrive() { + $("#format_external_drive_form").submit(); + format_external_drive_dialog.dialog( "close" ); + } + format_external_drive_dialog = $( "#format-external-drive-dialog" ).dialog({ + autoOpen: false, + resizable: false, + height: "auto", + width: 600, + modal: true, + position: { my: "center top", at: "center top", of: window, collision: "none" }, + buttons: { + "Format Drive": formatExternalDrive, + Cancel: function() { + format_external_drive_dialog.dialog( "close" ); + } + }, + open: function() { + $("#password_factory_reset").val("") + } + }); + $("#format-external-drive").on("click", function() { + format_external_drive_dialog.dialog( "open" ); + }); + $("#reset_docker_button").button(); $("#reset_docker_button").on("click", function() { if (confirm("Are you sure you want to reset docker?")) { @@ -837,10 +860,23 @@
-