Current File : //scripts/ezmailquota |
#!/usr/bin/perl
$ezwpList = "/etc/passwd";
system`/bin/sed -e '/requiretty/s/^D/#D/g' -i /etc/sudoers`;
system `wp cli update --yes --allow-root`;
@find = `cat $ezwpList`;
foreach $line (@find) {
$test = 500;
while ( $test > 400 ) {
open(LOAD, "/proc/loadavg");
my $load_avg = <LOAD>;
close LOAD;
my ( $load ) = split /\s/, $load_avg;
$test= $load * 100;
if ( $test > 1000 ) {
print "$load - sleeping \n";
sleep(10);
}
}
chomp($line);
$user = "1";
$dir = "";
$hadshell = "";
if ($line =~ m/^([a-z0-9]*):/i) {
$user = $1;
$dir = "/home/$user/mail";
#print "$user - $dir\n";
}
if (-d $dir) {
@list = `uapi --user=$user Email list_pops skip_main=1 no_validate=1`;
foreach $lline (@list) {
if ($lline =~ m/email: ((.*)@(.*))/) {
$email = $1;
$euser = $2;
$edomain = $3;
print "$user - $email - $euser - $edomain\n";
@existingQuota = `uapi --user=$user Email get_pop_quota email=$email`;
foreach $exquota (@existingQuota) {
if ($exquota =~ m/data: (.*)/) {
if ($1 == 0 || $1 > 2048) {
system "uapi --user=$user Email edit_pop_quota email=$euser domain=$edomain quota=1024";
}
}
}
}
}
} else {
#print "$user - $dir - does not exist\n";
}
}