diff --git a/mount/acl_security.pl b/mount/acl_security.pl index 487846baa..df0ceb0fc 100755 --- a/mount/acl_security.pl +++ b/mount/acl_security.pl @@ -33,7 +33,10 @@ print " $text{'acl_browse'}\n"; print "",&ui_radio("browse", $_[0]->{'browse'}, [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]),"\n"; -print "\n"; +print "$text{'acl_sysinfo'}\n"; +print "",&ui_radio("sysinfo", $_[0]->{'sysinfo'}, + [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ])," \n"; + } # acl_security_save(&options) @@ -47,5 +50,6 @@ $_[0]->{'create'} = $in{'create'}; $_[0]->{'user'} = $in{'user'}; $_[0]->{'hide'} = $in{'hide'}; $_[0]->{'browse'} = $in{'browse'}; +$_[0]->{'sysinfo'} = $in{'sysinfo'}; } diff --git a/mount/config.info b/mount/config.info index 04ba53c87..834024882 100644 --- a/mount/config.info +++ b/mount/config.info @@ -5,6 +5,7 @@ long_fstypes=Show long filesystem type names,1,1-Yes,0-No sort_mode=Sort filesystems by,1,2-Mount point,1-Type,0-Order in files show_used=Show used disk space in filesystems list,1,1-Yes,0-No delete_under=Delete directory when un-mounting if under,3,Never delete +sysinfo=Show available disk data on Dashboard?,1,1-Yes,0-No line2=System configuration,11 fstab_file=File listing filesystems mounted at boot time,0 auto_file=NFS automounts file,3 diff --git a/mount/defaultacl b/mount/defaultacl index 13caaf299..f8de07940 100644 --- a/mount/defaultacl +++ b/mount/defaultacl @@ -4,3 +4,4 @@ noconfig=0 user=0 hide=0 browse=1 +sysinfo=1 diff --git a/mount/lang/en b/mount/lang/en index 81060e2e4..aa0186446 100644 --- a/mount/lang/en +++ b/mount/lang/en @@ -495,4 +495,8 @@ freebsd_edevfile=The device file '$1' does not exist cswap_file=The swap file $1 does not exist. cswap_size=Create and mount a swap file with size +acl_sysinfo=Show available disk data on Dashboard? +sysinfo_total=Total +sysinfo_dev=Device ID + __norefs=1 diff --git a/mount/system_info.pl b/mount/system_info.pl new file mode 100644 index 000000000..465779674 --- /dev/null +++ b/mount/system_info.pl @@ -0,0 +1,50 @@ +do 'mount-lib.pl'; + +sub list_system_info +{ + my $can = &foreign_available($module_name) && $access{'sysinfo'}; + + if ((length($config{'sysinfo'}) && !$config{'sysinfo'}) || !$can) { + return (); + } + + my @disk_space = defined(&mount::local_disk_space) ? mount::local_disk_space() : (); + my $desc = ucwords($text{'edit_usage'}); + my $html; + if (@disk_space) { + $html = ui_columns_start( + [ucwords($text{'index_dir'}), ucwords($text{'index_type'}), + ucwords($text{'edit_free'}), ucwords($text{'sysinfo_total'}), + ucwords($text{'sysinfo_dev'}), + ]); + foreach my $disks (@disk_space) { + if (ref($disks)) { + foreach my $disk (@$disks) { + my $dev_id = $disk->{'device'}; + my $dir = $disk->{'dir'}; + my $type = $disk->{'type'}; + my $total = $disk->{'total'}; + my $total_nice = nice_size($disk->{'total'}); + my $free = $disk->{'free'}; + my $free_nice = nice_size($disk->{'free'}); + my $free_percent = int(($total - $free) / $total * 100); + $html .= ui_columns_row([$dir, $type, $free_percent . "% ($free_nice)", $total_nice, $dev_id,]); + } + } + } + $html .= ui_columns_end(); + } + return ( + { 'type' => 'html', + 'desc' => $desc, + 'open' => 1, + 'id' => $module_name . '_disks_info', + 'html' => $html + }); +} + +sub ucwords +{ + $_[0] =~ s/(\w+)/\u$1/g; + return $_[0]; +}