From 32e38df0a90e2b4aa5f209b82d6967923768bb6e Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sat, 31 Mar 2018 10:22:40 +0200 Subject: [PATCH] implement partiton table deletion --- addon/lib/rmupdate.tcl | 4 ++++ addon/www/index.html | 45 ++++++++++++++++++++++++++++++++++++++++++ addon/www/rest.cgi | 4 ++++ 3 files changed, 53 insertions(+) diff --git a/addon/lib/rmupdate.tcl b/addon/lib/rmupdate.tcl index ed68945..427102d 100644 --- a/addon/lib/rmupdate.tcl +++ b/addon/lib/rmupdate.tcl @@ -393,6 +393,10 @@ proc ::rmupdate::get_partion_start_end_and_size {device partition} { return $res } +proc ::rmupdate::delete_partition_table {device} { + exec /bin/dd if=/dev/zero of=$device bs=512 count=1 2>/dev/null +} + proc ::rmupdate::is_system_upgradeable {} { set sys_dev [get_system_device] #if { [get_filesystem_label $sys_dev 2] != "rootfs1" } { diff --git a/addon/www/index.html b/addon/www/index.html index a88abfe..33d366e 100644 --- a/addon/www/index.html +++ b/addon/www/index.html @@ -414,6 +414,30 @@ along with this program. If not, see . }) .modal('show'); })); + + if (partition.partition == 0) { + menu_items.push($('').append(i18next.t('delete_partition_table')).attr('data-device', device).click(function() { + var device = this.getAttribute('data-device'); + $('#modal-delete-partition-table').modal({ + onDeny: function() { + return true; + }, + onApprove: function() { + rest('POST', '/delete_partition_table', JSON.stringify({"device":device}), + function(data) { + display_message('success', i18next.t('partiton_table_deleted'), 120000); + get_partitions(); + }, + function(xhr, ajaxOptions, thrownError) { + default_error_callback(xhr, ajaxOptions, thrownError); + get_partitions(); + } + ); + } + }) + .modal('show'); + })); + } } var menu = null; if (menu_items.length > 0) { @@ -680,6 +704,10 @@ along with this program. If not, see . move: 'Move', moving_userfs: 'Moving userfs, please wait, this will take a while...', userfs_moved: 'Userfs moved, system will reboot now.', + delete_partition_table: 'Delete partition table.', + sure_to_delete_partition_table: 'Are you sure you want to delete the partition table?', + delete: 'Delete', + partiton_table_deleted: 'Partiton table deleted.', firmwares: 'Firmwares', current_installed_version: 'Current installed version', latest_available_version: 'Latest available version', @@ -759,6 +787,10 @@ along with this program. If not, see . move: 'Verschieben', moving_userfs: 'Verschiebe userfs, bitte warten, dies kann einige Zeit dauern...', userfs_moved: 'Userfs wurde verschoben, das System wird neu gestartet.', + delete_partition_table: 'Partitionstabelle löschen.', + sure_to_delete_partition_table: 'Soll die Partitionstabelle wirklich gelöscht werden?', + delete: 'Löschen', + partiton_table_deleted: 'Partitionstabelle gelöscht.', firmwares: 'Firmwares', current_installed_version: 'Momentan installierte Version', latest_available_version: 'Aktuellste verfügbare Version', @@ -1096,6 +1128,19 @@ along with this program. If not, see . + +