Index: [Article Count Order] [Thread]

Date:  Wed, 24 Dec 2008 02:46:17 +0100
From:  Michael Stauber <bq (at mark) solarspeed.net>
Subject:  [coba-e:14532] Re: Change quota on multiple users
To:  coba-e (at mark) bluequartz.org
Message-Id:  <200812240246.17862.bq (at mark) solarspeed.net>
In-Reply-To:  <495151C4.9060506 (at mark) virtbiz.com>
References:  <495151C4.9060506 (at mark) virtbiz.com>
X-Mail-Count: 14532

Hi Chris,

> We have a customer that would like to increase quota globally across
> over 100 users on their site.
>
> Is there a good way to automate this?  Clicking through each user in the
> GUI will be a slow process.

Small Perl or shell script, wrapped around the CMU Shell Tools would do 
nicely.

First create a textfile with the name of all users of that site in it. Lets 
say the site is "site1". In that case you can use the command as shown below:

/usr/sausalito/sbin/get_quotas.pl --site=site1 | awk '{print $1}'| grep -v 
SITE > /root/userlist.txt

Afterwards you'll have the textfile /root/userlist.txt with all usernames of 
that site -  one username by line.

Then create the perl script /root/userquota.pl and put this in it:

---------------------------------------------------------------------------------------
#!/usr/bin/perl 

# Desired Quota in MB:
$size = 100
open( UFILE, "/root/userlist.txt") || die "Cannot open /root/userlist.txt";
while ( <UFILE>) {
        chop;
        ($user) = split /\//;
        print "Setting quota for " .  $user . " to " . $size . " MB. \n";
        system ("/usr/sbin/cmoduser --name $user --set-quota $size");
}
close (UFILE);
---------------------------------------------------------------------------------------

That script will then set all users from the textfile to a quota of 100MB.

-- 
With best regards,

Michael Stauber