mirror of
https://github.com/j-a-n/raspberrymatic-addon-rmupdate.git
synced 2023-10-10 13:37:40 +02:00
Implement userfs move
This commit is contained in:
parent
469efb9ee1
commit
a3b18ab3b4
@ -710,19 +710,15 @@ proc ::rmupdate::move_userfs_to_device {target_device {sync_data 0} {repartition
|
|||||||
}
|
}
|
||||||
|
|
||||||
set source_partition_device [get_mounted_device "/usr/local"]
|
set source_partition_device [get_mounted_device "/usr/local"]
|
||||||
set source_device [string range $source_partition_device 0 end-1]
|
set source_device [get_disk_device $source_partition_device]
|
||||||
if { [regexp {mmcblk} $source_partition_device match] } {
|
|
||||||
set source_device [string range $source_partition_device 0 end-2]
|
|
||||||
}
|
|
||||||
|
|
||||||
if { $source_device == ""} {
|
if {$source_partition_device == "" || $source_device == ""} {
|
||||||
error [i18n "Failed to find source device for /usr/local."]
|
error [i18n "Failed to find source device for /usr/local."]
|
||||||
}
|
}
|
||||||
if { $source_device == $target_device} {
|
if {$source_device == $target_device} {
|
||||||
error [i18n "Source and target are the same device."]
|
error [i18n "Source and target are the same device."]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if {$target_partition_device == ""} {
|
if {$target_partition_device == ""} {
|
||||||
set partition_number 0
|
set partition_number 0
|
||||||
if {$repartition == 1} {
|
if {$repartition == 1} {
|
||||||
@ -774,8 +770,8 @@ proc ::rmupdate::move_userfs_to_device {target_device {sync_data 0} {repartition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch { exec tune2fs -L 0userfs $source_partition_device }
|
catch { exec /sbin/tune2fs -L 0userfs $source_partition_device }
|
||||||
catch { exec tune2fs -L userfs $target_partition_device }
|
catch { exec /sbin/tune2fs -L userfs $target_partition_device }
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ::rmupdate::clone_system {target_device {activate_clone 0}} {
|
proc ::rmupdate::clone_system {target_device {activate_clone 0}} {
|
||||||
@ -1533,3 +1529,4 @@ proc ::rmupdate::wlan_disconnect {} {
|
|||||||
#puts [rmupdate::get_partitions]
|
#puts [rmupdate::get_partitions]
|
||||||
#puts [array_to_json [rmupdate::get_partitions]]
|
#puts [array_to_json [rmupdate::get_partitions]]
|
||||||
#rmupdate::move_userfs_to_device /dev/sda1 1 0
|
#rmupdate::move_userfs_to_device /dev/sda1 1 0
|
||||||
|
#puts [rmupdate::get_mounted_device "/usr/local"]
|
||||||
|
@ -38,6 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
var current_firmware = '?';
|
var current_firmware = '?';
|
||||||
var latest_firmware = '?';
|
var latest_firmware = '?';
|
||||||
var wlanScanTimer;
|
var wlanScanTimer;
|
||||||
|
var moving_userfs_to_device = false;
|
||||||
|
|
||||||
function display_message(type, text, millis) {
|
function display_message(type, text, millis) {
|
||||||
clear_message();
|
clear_message();
|
||||||
@ -326,14 +327,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
data.forEach(function(partition) {
|
data.forEach(function(partition) {
|
||||||
if (partition.partition == 0) {
|
if (partition.partition == 0) {
|
||||||
disks[partition.disk_device] = partition;
|
disks[partition.disk_device] = partition;
|
||||||
disks[partition.disk_device].usr_local_on_disk = false;
|
disks[partition.disk_device].userfs_on_disk = false;
|
||||||
|
disks[partition.disk_device].bootfs_on_disk = false;
|
||||||
disks[partition.disk_device].partitions = {};
|
disks[partition.disk_device].partitions = {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
data.forEach(function(partition) {
|
data.forEach(function(partition) {
|
||||||
disks[partition.disk_device].partitions[partition.partition] = partition;
|
disks[partition.disk_device].partitions[partition.partition] = partition;
|
||||||
if (partition.mountpoint == '/usr/local') {
|
if (partition.mountpoint == '/usr/local') {
|
||||||
disks[partition.disk_device].usr_local_on_disk = true;
|
disks[partition.disk_device].userfs_on_disk = true;
|
||||||
|
}
|
||||||
|
else if (partition.mountpoint == '/boot') {
|
||||||
|
disks[partition.disk_device].bootfs_on_disk = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#volume-info tbody').empty();
|
$('#volume-info tbody').empty();
|
||||||
@ -345,7 +350,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
var partition = disks[disk_device].partitions[part];
|
var partition = disks[disk_device].partitions[part];
|
||||||
|
|
||||||
var menu_items = [];
|
var menu_items = [];
|
||||||
if (! disks[disk_device].usr_local_on_disk) {
|
var skip_dev = false;
|
||||||
|
if (disks[disk_device].userfs_on_disk) {
|
||||||
|
skip_dev = true;
|
||||||
|
}
|
||||||
|
else if (disks[disk_device].bootfs_on_disk && (partition.partition == 0)) {
|
||||||
|
skip_dev = true;
|
||||||
|
}
|
||||||
|
else if ((partition.partition > 0) && (partition.filesystem_label == 'bootfs' || partition.filesystem_label == 'rootfs' || partition.filesystem_label == 'rootfs1' || partition.filesystem_label == 'rootfs2')) {
|
||||||
|
skip_dev = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! skip_dev) {
|
||||||
var device = partition.disk_device;
|
var device = partition.disk_device;
|
||||||
var label = i18next.t('use_disk_for_userfs');
|
var label = i18next.t('use_disk_for_userfs');
|
||||||
if (partition.partition > 0) {
|
if (partition.partition > 0) {
|
||||||
@ -355,15 +371,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
menu_items.push($('<a class="item">').append(label).attr('data-device', device).click(function() {
|
menu_items.push($('<a class="item">').append(label).attr('data-device', device).click(function() {
|
||||||
var target_device = this.getAttribute('data-device');
|
var target_device = this.getAttribute('data-device');
|
||||||
$('#modal-move-userfs').modal({
|
$('#modal-move-userfs').modal({
|
||||||
onDeny: function(){
|
onDeny: function() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onApprove: function() {
|
onApprove: function() {
|
||||||
rest('POST', '/move_userfs_to_device', JSON.stringify({"target_device":target_device}), function(data) {
|
moving_userfs_to_device = true;
|
||||||
display_message('success', i18next.t('userfs_moved'), 120000);
|
display_message('warning', i18next.t('moving_userfs'), 300000);
|
||||||
rest('POST', '/system_reboot');
|
rest('POST', '/move_userfs_to_device', JSON.stringify({"target_device":target_device}),
|
||||||
});
|
function(data) {
|
||||||
return true;
|
moving_userfs_to_device = false;
|
||||||
|
display_message('success', i18next.t('userfs_moved'), 120000);
|
||||||
|
rest('POST', '/system_reboot');
|
||||||
|
},
|
||||||
|
function(xhr, ajaxOptions, thrownError) {
|
||||||
|
moving_userfs_to_device = false;
|
||||||
|
default_error_callback(xhr, ajaxOptions, thrownError);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.modal('show');
|
.modal('show');
|
||||||
@ -371,7 +395,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
}
|
}
|
||||||
var menu = null;
|
var menu = null;
|
||||||
if (menu_items.length > 0) {
|
if (menu_items.length > 0) {
|
||||||
menu = $('<div class="ui compact menu" style="min-height:30px; max-height: 30px;">').append(
|
menu = $('<div class="ui compact menu" style="min-height:28px; max-height:28px;">').append(
|
||||||
$('<div class="ui dropdown item">').append(
|
$('<div class="ui dropdown item">').append(
|
||||||
i18next.t('action'),
|
i18next.t('action'),
|
||||||
$('<i class="dropdown icon">'),
|
$('<i class="dropdown icon">'),
|
||||||
@ -621,6 +645,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
move_userfs: 'Move userfs to another device',
|
move_userfs: 'Move userfs to another device',
|
||||||
sure_to_move_userfs: 'Are you sure you want to move userfs?',
|
sure_to_move_userfs: 'Are you sure you want to move userfs?',
|
||||||
move: 'Move',
|
move: 'Move',
|
||||||
|
moving_userfs: 'Moving userfs, please wait, this will take a while...',
|
||||||
userfs_moved: 'Userfs moved, system will reboot now.',
|
userfs_moved: 'Userfs moved, system will reboot now.',
|
||||||
firmwares: 'Firmwares',
|
firmwares: 'Firmwares',
|
||||||
current_installed_version: 'Current installed version',
|
current_installed_version: 'Current installed version',
|
||||||
@ -697,6 +722,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
move_userfs: 'Userfs auf anderen Datenträger verschieben',
|
move_userfs: 'Userfs auf anderen Datenträger verschieben',
|
||||||
sure_to_move_userfs: 'Soll das userfs wirklich verschoben werden?',
|
sure_to_move_userfs: 'Soll das userfs wirklich verschoben werden?',
|
||||||
move: 'Verschieben',
|
move: 'Verschieben',
|
||||||
|
moving_userfs: 'Verschiebe userfs, bitte warten, dies kann einige Zeit dauern...',
|
||||||
userfs_moved: 'Userfs wurde verschoben, das System wird neu gestartet.',
|
userfs_moved: 'Userfs wurde verschoben, das System wird neu gestartet.',
|
||||||
firmwares: 'Firmwares',
|
firmwares: 'Firmwares',
|
||||||
current_installed_version: 'Momentan installierte Version',
|
current_installed_version: 'Momentan installierte Version',
|
||||||
|
Loading…
Reference in New Issue
Block a user