mirror of
https://github.com/j-a-n/raspberrymatic-addon-rmupdate.git
synced 2023-10-10 13:37:40 +02:00
Show partition info
This commit is contained in:
parent
507314f45e
commit
b5ac6685ae
@ -1,6 +1,6 @@
|
|||||||
# RaspMatic update addon
|
# RaspMatic update addon
|
||||||
#
|
#
|
||||||
# Copyright (C) 2017 Jan Schneider <oss@janschneider.net>
|
# Copyright (C) 2018 Jan Schneider <oss@janschneider.net>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -252,6 +252,24 @@ proc ::rmupdate::get_partitions {{device ""}} {
|
|||||||
} else {
|
} else {
|
||||||
set data [exec /sbin/fdisk -l]
|
set data [exec /sbin/fdisk -l]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set root_partuuid ""
|
||||||
|
set fd [open "/proc/cmdline" r]
|
||||||
|
set cmdline_data [read $fd]
|
||||||
|
close $fd
|
||||||
|
foreach d [split $cmdline_data "\n"] {
|
||||||
|
if { [regexp {root=PARTUUID=(\S+)} $d match partuuid] } {
|
||||||
|
set root_partuuid $partuuid
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#set fd [open /etc/mtab r]
|
||||||
|
#set mtab_data [read $fd]
|
||||||
|
#close $fd
|
||||||
|
|
||||||
|
set df_data [exec /bin/df -a -T]
|
||||||
|
|
||||||
foreach d [split $data "\n"] {
|
foreach d [split $data "\n"] {
|
||||||
if {[regexp {Disk\s+(\S+):.*\s(\d+)\s+bytes} $d match dev size]} {
|
if {[regexp {Disk\s+(\S+):.*\s(\d+)\s+bytes} $d match dev size]} {
|
||||||
set partitions(${dev}::0::partition) 0
|
set partitions(${dev}::0::partition) 0
|
||||||
@ -269,6 +287,24 @@ proc ::rmupdate::get_partitions {{device ""}} {
|
|||||||
set partitions(${dev}::${num}::start) $start
|
set partitions(${dev}::${num}::start) $start
|
||||||
set partitions(${dev}::${num}::end) $end
|
set partitions(${dev}::${num}::end) $end
|
||||||
set partitions(${dev}::${num}::size) $size
|
set partitions(${dev}::${num}::size) $size
|
||||||
|
set partitions(${dev}::${num}::partition_uuid) ""
|
||||||
|
set partitions(${dev}::${num}::filesystem_label) ""
|
||||||
|
set partitions(${dev}::${num}::filesystem_uuid) ""
|
||||||
|
set partitions(${dev}::${num}::filesystem_type) ""
|
||||||
|
set partitions(${dev}::${num}::mountpoint) ""
|
||||||
|
set partitions(${dev}::${num}::filesystem_size) -1
|
||||||
|
set partitions(${dev}::${num}::filesystem_used) -1
|
||||||
|
set partitions(${dev}::${num}::filesystem_avail) -1
|
||||||
|
set partitions(${dev}::${num}::filesystem_usage) -1
|
||||||
|
|
||||||
|
foreach f [glob /dev/disk/by-partuuid/*] {
|
||||||
|
catch {
|
||||||
|
if { [file tail [file readlink $f]] == [file tail $part_dev] } {
|
||||||
|
set partitions(${dev}::${num}::partition_uuid) [file tail $f]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set data3 [exec /sbin/blkid $part_dev]
|
set data3 [exec /sbin/blkid $part_dev]
|
||||||
foreach d3 [split $data3 "\n"] {
|
foreach d3 [split $data3 "\n"] {
|
||||||
@ -283,11 +319,32 @@ proc ::rmupdate::get_partitions {{device ""}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach f [glob /dev/disk/by-partuuid/*] {
|
#foreach d4 [split $mtab_data "\n"] {
|
||||||
catch {
|
# if { [regexp {^(\S+)\s+(\S+)\s+} $d4 match md mp] } {
|
||||||
if { [file tail [file readlink $f]] == [file tail $part_dev] } {
|
# if {$md == $part_dev} {
|
||||||
set partitions(${dev}::${num}::partition_uuid) [file tail $f]
|
# set partitions(${dev}::${num}::mountpoint) $mp
|
||||||
|
# break
|
||||||
|
# } elseif {$mp == "/" && $partitions(${dev}::${num}::partition_uuid) == $root_partuuid} {
|
||||||
|
# set partitions(${dev}::${num}::mountpoint) $mp
|
||||||
|
# break
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Filesystem Type 1K-blocks Used Available Use% Mounted on
|
||||||
|
# /dev/root ext4 991512 346288 577640 37% /
|
||||||
|
foreach d4 [split $df_data "\n"] {
|
||||||
|
if { [regexp {^(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\S+)\s*$} $d4 match dd dt ds du da dp dm] } {
|
||||||
|
if {$dd == $part_dev} {
|
||||||
|
} elseif {$dm == "/" && $partitions(${dev}::${num}::partition_uuid) == $root_partuuid} {
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
set partitions(${dev}::${num}::mountpoint) $dm
|
||||||
|
set partitions(${dev}::${num}::filesystem_size) [format "%0.0f" [expr {$ds * 1024.0}]]
|
||||||
|
set partitions(${dev}::${num}::filesystem_used) [format "%0.0f" [expr {$du * 1024.0}]]
|
||||||
|
set partitions(${dev}::${num}::filesystem_avail) [format "%0.0f" [expr {$da * 1024.0}]]
|
||||||
|
set partitions(${dev}::${num}::filesystem_usage) [expr {$dp / 100.0}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
RaspMatic update addon
|
RaspMatic update addon
|
||||||
|
|
||||||
Copyright (C) 2017 Jan Schneider <oss@janschneider.net>
|
Copyright (C) 2018 Jan Schneider <oss@janschneider.net>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -114,6 +114,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
}
|
}
|
||||||
|
|
||||||
function disable_buttons() {
|
function disable_buttons() {
|
||||||
|
$('#install-latest-firmware-button').addClass('disabled');
|
||||||
$('[data-install-firmware-version]').addClass('disabled');
|
$('[data-install-firmware-version]').addClass('disabled');
|
||||||
$('[data-delete-firmware-version]').addClass('disabled');
|
$('[data-delete-firmware-version]').addClass('disabled');
|
||||||
$('[data-update-addon-id]').addClass('disabled');
|
$('[data-update-addon-id]').addClass('disabled');
|
||||||
@ -123,6 +124,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reset_buttons() {
|
function reset_buttons() {
|
||||||
|
$('#install-latest-firmware-button').removeClass('loading');
|
||||||
|
$('#install-latest-firmware-button').removeClass('disabled');
|
||||||
$('[data-install-firmware-version]').removeClass('loading');
|
$('[data-install-firmware-version]').removeClass('loading');
|
||||||
$('[data-install-firmware-version]').removeClass('disabled');
|
$('[data-install-firmware-version]').removeClass('disabled');
|
||||||
$('[data-delete-firmware-version]').removeClass('disabled');
|
$('[data-delete-firmware-version]').removeClass('disabled');
|
||||||
@ -282,7 +285,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
);
|
);
|
||||||
if (current_firmware != latest_firmware) {
|
if (current_firmware != latest_firmware) {
|
||||||
$("#firmware-summary").append(
|
$("#firmware-summary").append(
|
||||||
$('<div class="ui green basic button" style="margin-top:20px; margin-bottom:20px;">').click(install_latest_firmware).append($('<i class="sign in icon">'), i18next.t('install_latest_firmware'))
|
$('<div id="install-latest-firmware-button" class="ui green basic button" style="margin-top:20px; margin-bottom:20px;">').click(install_latest_firmware).append($('<i class="sign in icon">'), i18next.t('install_latest_firmware'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,13 +300,69 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
rest("GET", "/get_system_info", null, function(data) {
|
rest("GET", "/get_system_info", null, function(data) {
|
||||||
$("#system-info").empty();
|
$("#system-info").empty();
|
||||||
$("#system-info").append(
|
$("#system-info").append(
|
||||||
$('<div class="item">').html(i18next.t('system_type', {'system_type': data.system_type})),
|
$('<div class="item">').html(i18next.t('system_type', {'system_type': data.system_type}))
|
||||||
$('<div class="item">').html(i18next.t('current_root_partiton', {'root_partition': data.root_partition})),
|
|
||||||
$('<div class="item">').html(i18next.t('current_user_partiton', {'user_partition': data.user_partition}))
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function format_size(size) {
|
||||||
|
if (size > 1024 * 1024 * 1024) {
|
||||||
|
return (parseInt(size)/1024/1024/1024).toFixed(1) + ' GB'
|
||||||
|
}
|
||||||
|
else if (size > 1024 * 1024) {
|
||||||
|
return (parseInt(size)/1024/1024).toFixed(1) + ' MB'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (parseInt(size)/1024).toFixed(1) + ' KB'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_partitions() {
|
||||||
|
$('#dimmer-partition-info').addClass('active');
|
||||||
|
rest("GET", "/get_partitions", null, function(data) {
|
||||||
|
var disks = {};
|
||||||
|
data.forEach(function(partition) {
|
||||||
|
if (partition.partition == 0) {
|
||||||
|
disks[partition.disk_device] = {};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
data.forEach(function(partition) {
|
||||||
|
disks[partition.disk_device][partition.partition] = partition;
|
||||||
|
});
|
||||||
|
$('#partition-info tbody').empty();
|
||||||
|
for (var disk_device in disks) {
|
||||||
|
parts = Object.keys(disks[disk_device]);
|
||||||
|
parts.sort();
|
||||||
|
for (var part in parts) {
|
||||||
|
var partition = disks[disk_device][part];
|
||||||
|
if (partition.partition == 0) {
|
||||||
|
var st = "border:none; border-top: 2px solid #aaafaf";
|
||||||
|
$("#partition-info tbody").append($('<tr style="background: #f8ffff;">').append(
|
||||||
|
$('<td style="'+st+'" class="top aligned" rowspan="' + parts.length + '">').append($('<label>' + partition.disk_device + '</label>')),
|
||||||
|
$('<td style="'+st+'" class="center aligned" colspan="4">'),
|
||||||
|
$('<td style="'+st+'">').append($('<label>' + format_size(partition.size) + '</label>')),
|
||||||
|
$('<td style="'+st+'">')
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
var usage = '';
|
||||||
|
if (partition.filesystem_usage && partition.filesystem_usage >= 0) {
|
||||||
|
usage = (parseFloat(partition.filesystem_usage) * 100).toFixed(0) + '%'
|
||||||
|
}
|
||||||
|
$("#partition-info tbody").append($('<tr>').append(
|
||||||
|
$('<td style="border-left: 1px solid rgba(34,36,38,.1)">').append($('<label>' + partition.partition + '</label>')),
|
||||||
|
$('<td>').append($('<label>' + partition.filesystem_type + '</label>')),
|
||||||
|
$('<td>').append($('<label>' + partition.filesystem_label + '</label>')),
|
||||||
|
$('<td>').append($('<label>' + partition.mountpoint + '</label>')),
|
||||||
|
$('<td>').append($('<label>' + format_size(partition.size) + '</label>')),
|
||||||
|
$('<td>').append($('<label>' + usage + '</label>'))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#dimmer-partition-info').removeClass('active');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function install_addon(addon_id, download_url, file_input) {
|
function install_addon(addon_id, download_url, file_input) {
|
||||||
if (!running_installation) {
|
if (!running_installation) {
|
||||||
display_message('info', i18next.t('installing_addon', {'addon_id': addon_id}), 180000);
|
display_message('info', i18next.t('installing_addon', {'addon_id': addon_id}), 180000);
|
||||||
@ -491,8 +550,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
translation: {
|
translation: {
|
||||||
title: 'System update',
|
title: 'System update',
|
||||||
system_info: 'System information',
|
system_info: 'System information',
|
||||||
current_root_partiton: 'Current root partition: {{root_partition}}',
|
|
||||||
current_user_partiton: 'Current user partition: {{user_partition}}',
|
|
||||||
system_type: 'System type: {{system_type}}',
|
system_type: 'System type: {{system_type}}',
|
||||||
reboot_system: 'Reboot system',
|
reboot_system: 'Reboot system',
|
||||||
shutdown_system: 'Shutdown system',
|
shutdown_system: 'Shutdown system',
|
||||||
@ -502,6 +559,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
sure_to_shutdown_system: 'Are you sure you want to shutdown the system now?',
|
sure_to_shutdown_system: 'Are you sure you want to shutdown the system now?',
|
||||||
system_is_rebooting: 'System is going down for reboot now.',
|
system_is_rebooting: 'System is going down for reboot now.',
|
||||||
system_is_shutting_down: 'System is going down for shutdown now.',
|
system_is_shutting_down: 'System is going down for shutdown now.',
|
||||||
|
partitions: 'Partitions',
|
||||||
|
device: 'Device',
|
||||||
|
partition_number: 'Partition',
|
||||||
|
filesystem_type: 'Filesystem',
|
||||||
|
filesystem_label: 'Label',
|
||||||
|
mountpoint: 'Mountpoint',
|
||||||
|
size: 'Size',
|
||||||
|
usage: 'Usage',
|
||||||
firmwares: 'Firmwares',
|
firmwares: 'Firmwares',
|
||||||
current_installed_version: 'Current installed version',
|
current_installed_version: 'Current installed version',
|
||||||
latest_available_version: 'Latest available version',
|
latest_available_version: 'Latest available version',
|
||||||
@ -553,8 +618,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
translation: {
|
translation: {
|
||||||
title: 'System-Aktualisierung',
|
title: 'System-Aktualisierung',
|
||||||
system_info: 'System-Informationen',
|
system_info: 'System-Informationen',
|
||||||
current_root_partiton: 'Aktuelle Root-Partition: {{root_partition}}',
|
|
||||||
current_user_partiton: 'Aktuelle User-Partition: {{user_partition}}',
|
|
||||||
system_type: 'System-Typ: {{system_type}}',
|
system_type: 'System-Typ: {{system_type}}',
|
||||||
reboot_system: 'System neu starten',
|
reboot_system: 'System neu starten',
|
||||||
shutdown_system: 'System herunterfahren',
|
shutdown_system: 'System herunterfahren',
|
||||||
@ -564,6 +627,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
sure_to_shutdown_system: 'Soll das System jetzt heruntergefahren werden?',
|
sure_to_shutdown_system: 'Soll das System jetzt heruntergefahren werden?',
|
||||||
system_is_rebooting: 'Das System wird neu gestartet.',
|
system_is_rebooting: 'Das System wird neu gestartet.',
|
||||||
system_is_shutting_down: 'Das System wird heruntergefahren.',
|
system_is_shutting_down: 'Das System wird heruntergefahren.',
|
||||||
|
partitions: 'Partitionen',
|
||||||
|
device: 'Gerät',
|
||||||
|
partition_number: 'Partition',
|
||||||
|
filesystem_type: 'Dateisystem',
|
||||||
|
filesystem_label: 'Label',
|
||||||
|
mountpoint: 'Einhängepunkt',
|
||||||
|
size: 'Größe',
|
||||||
|
usage: 'Belegt',
|
||||||
firmwares: 'Firmwares',
|
firmwares: 'Firmwares',
|
||||||
current_installed_version: 'Momentan installierte Version',
|
current_installed_version: 'Momentan installierte Version',
|
||||||
latest_available_version: 'Aktuellste verfügbare Version',
|
latest_available_version: 'Aktuellste verfügbare Version',
|
||||||
@ -654,6 +725,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
get_system_info();
|
get_system_info();
|
||||||
|
get_partitions();
|
||||||
get_firmware_info();
|
get_firmware_info();
|
||||||
get_addon_info();
|
get_addon_info();
|
||||||
wlan_scan();
|
wlan_scan();
|
||||||
@ -684,6 +756,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<div class="ui orange basic button" data-i18n="reboot_system" onclick="show_reboot_dialog();"></div>
|
<div class="ui orange basic button" data-i18n="reboot_system" onclick="show_reboot_dialog();"></div>
|
||||||
<div class="ui red basic button" data-i18n="shutdown_system" onclick="show_shutdown_dialog();"></div>
|
<div class="ui red basic button" data-i18n="shutdown_system" onclick="show_shutdown_dialog();"></div>
|
||||||
|
|
||||||
|
<h2 class="ui header">
|
||||||
|
<i class="hdd outline icon"></i>
|
||||||
|
<div data-i18n="partitions" class="content">
|
||||||
|
</div>
|
||||||
|
</h2>
|
||||||
|
<div class="dimmable">
|
||||||
|
<div id="dimmer-partition-info" class="ui active inverted dimmer">
|
||||||
|
<div class="ui loader" data-i18n="loading"></div>
|
||||||
|
</div>
|
||||||
|
<table id="partition-info" class="ui celled stackable table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-i18n="device"></th>
|
||||||
|
<th data-i18n="partition_number"></th>
|
||||||
|
<th data-i18n="filesystem_type"></th>
|
||||||
|
<th data-i18n="filesystem_label"></th>
|
||||||
|
<th data-i18n="mountpoint"></th>
|
||||||
|
<th data-i18n="size"></th>
|
||||||
|
<th data-i18n="usage"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2 class="ui header">
|
<h2 class="ui header">
|
||||||
<i class="settings icon"></i>
|
<i class="settings icon"></i>
|
||||||
<div data-i18n="firmwares" class="content">
|
<div data-i18n="firmwares" class="content">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# RaspMatic update addon
|
# RaspMatic update addon
|
||||||
#
|
#
|
||||||
# Copyright (C) 2017 Jan Schneider <oss@janschneider.net>
|
# Copyright (C) 2018 Jan Schneider <oss@janschneider.net>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -54,9 +54,9 @@ proc process {} {
|
|||||||
return [rmupdate::get_firmware_info]
|
return [rmupdate::get_firmware_info]
|
||||||
} elseif {[lindex $path 1] == "get_system_info"} {
|
} elseif {[lindex $path 1] == "get_system_info"} {
|
||||||
set system_type [rmupdate::get_rpi_version]
|
set system_type [rmupdate::get_rpi_version]
|
||||||
set root_partition [rmupdate::get_partition_device [rmupdate::get_system_device] [rmupdate::get_current_root_partition_number]]
|
return "\{\"system_type\":\"${system_type}\"\}"
|
||||||
set user_partition [rmupdate::get_mounted_device "/usr/local"]
|
} elseif {[lindex $path 1] == "get_partitions"} {
|
||||||
return "\{\"system_type\":\"${system_type}\",\"root_partition\":\"${root_partition}\",\"user_partition\":\"${user_partition}\"\}"
|
return [array_to_json [rmupdate::get_partitions]]
|
||||||
} elseif {[lindex $path 1] == "system_reboot"} {
|
} elseif {[lindex $path 1] == "system_reboot"} {
|
||||||
exec /sbin/reboot
|
exec /sbin/reboot
|
||||||
return "\"reboot initiated\""
|
return "\"reboot initiated\""
|
||||||
|
Loading…
Reference in New Issue
Block a user