Add uquota.pl
This commit is contained in:
34
uquota.pl
Normal file
34
uquota.pl
Normal file
@ -0,0 +1,34 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# Bare på nyere perl. Sukk.
|
||||
# use warnings;
|
||||
use strict;
|
||||
use Quota;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
my ($name,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell,$expire) = getpwuid($<);
|
||||
my ($block_curr, $block_soft, $block_hard, $block_timelimit, $inode_curr, $inode_soft, $inode_hard, $inode_timelimit) = Quota::query(Quota::getqcarg($dir));
|
||||
|
||||
if (! $block_hard && ! $block_soft) {
|
||||
print "Du har uendelig kvote.\n";
|
||||
}
|
||||
|
||||
my $filled = sprintf("%.1f", $block_curr * 100.0 / $block_soft);
|
||||
my $max = "(ingen maksimum)";
|
||||
if ($block_hard) {
|
||||
$max = sprintf("(max %.0f%%)",$block_hard * 100.0 / $block_soft);
|
||||
}
|
||||
|
||||
my $mb_curr = int($block_curr / 1024);
|
||||
my $mb_soft = int($block_soft / 1024);
|
||||
|
||||
my $days_timelimit = strftime("%Y-%m-%d %H:%M",localtime($block_timelimit));
|
||||
|
||||
print "Du har brukt ${mb_curr}MiB av ${mb_soft}MiB, eller ${filled}%.\n";
|
||||
if ($block_timelimit) {
|
||||
print "Du er over kvoten din ${max}, og etter $days_timelimit\n";
|
||||
print "vil du miste skrivetilgang frem til du har slettet nok til å\n";
|
||||
print "komme under 100% igjen.\n";
|
||||
} else {
|
||||
print "Du kan gå over kvoten din ${max} i opptil 7 dager.\n";
|
||||
}
|
Reference in New Issue
Block a user