[vhffs-dev] [2016] Reworked group and user quota bot

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2016
Author:   gradator
Date:     2012-02-18 03:18:53 +0100 (Sat, 18 Feb 2012)
Log Message:
-----------
Reworked group and user quota bot

Merged group_getquota and group_setquota to group_quota
Merged user_getquota and user_setquota to user_quota

Modified Paths:
--------------
    trunk/vhffs-robots/Makefile.am
    trunk/vhffs-robots/src/repository_quota.pl

Added Paths:
-----------
    trunk/vhffs-robots/src/group_quota.pl
    trunk/vhffs-robots/src/user_quota.pl

Removed Paths:
-------------
    trunk/vhffs-robots/src/group_getquota.pl
    trunk/vhffs-robots/src/group_setquota.pl
    trunk/vhffs-robots/src/user_getquota.pl
    trunk/vhffs-robots/src/user_setquota.pl

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2012-02-18 01:29:44 UTC (rev 2015)
+++ trunk/vhffs-robots/Makefile.am	2012-02-18 02:18:53 UTC (rev 2016)
@@ -29,8 +29,7 @@
 	src/dns_delete.pl \
 	src/group_create.pl \
 	src/group_delete.pl \
-	src/group_getquota.pl \
-	src/group_setquota.pl \
+	src/group_quota.pl \
 	src/listengine_publicarchives.pl \
 	src/mail_create.pl \
 	src/mail_createboxes.pl \
@@ -69,8 +68,7 @@
 	src/user_create.pl \
 	src/user_delete.pl \
 	src/user_group.pl \
-	src/user_setquota.pl \
-	src/user_getquota.pl \
+	src/user_quota.pl \
 	src/user_cleanup.pl \
 	src/web_create.pl \
 	src/web_delete.pl \

Deleted: trunk/vhffs-robots/src/group_getquota.pl
===================================================================
--- trunk/vhffs-robots/src/group_getquota.pl	2012-02-18 01:29:44 UTC (rev 2015)
+++ trunk/vhffs-robots/src/group_getquota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -1,68 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-require 5.004;
-use strict;
-use utf8;
-use POSIX;
-use locale;
-use Locale::gettext;
-use Quota;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Robots;
-use Vhffs::Group;
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "getquotagroup" );
-
-my $groups = Vhffs::Group::getall( $vhffs , Vhffs::Constants::ACTIVATED );
-my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
-
-foreach my $group ( @$groups ) {
-
-	(my $blocks,undef,undef,undef,undef,undef,undef,undef) = Quota::query($dev, $group->get_gid, 1);
-
-	if(defined($blocks)) {
-		my $used = ($blocks + 1024 - ($blocks % 1024)) / 1024;
-		if($group->get_quota_used() != $used) {
-			$group->set_quota_used( $used );
-			if( $group->commit > 0 ) {
-				Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s set %s" , $group->get_groupname , $used ) , $vhffs);
-			}
-		}   
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "getquotagroup" );
-
-exit 0;

Copied: trunk/vhffs-robots/src/group_quota.pl (from rev 2012, trunk/vhffs-robots/src/group_getquota.pl)
===================================================================
--- trunk/vhffs-robots/src/group_quota.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/group_quota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -0,0 +1,80 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+require 5.004;
+use strict;
+use utf8;
+use POSIX;
+use locale;
+use Locale::gettext;
+use Quota;
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Main;
+use Vhffs::Robots;
+use Vhffs::Group;
+
+my $vhffs = init Vhffs::Main;
+
+Vhffs::Robots::lock( $vhffs , 'quotagroup' );
+
+my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
+
+my $groups = Vhffs::Group::getall( $vhffs, Vhffs::Constants::ACTIVATED );
+foreach my $group ( @$groups ) {
+	my $setblocks = ceil( ($group->get_quota*1000000)/1024 );  # Filesystem quota block = 1024B
+	my $setinodes = ceil( ($group->get_quota*1000000)/4096 );  # Filesystem block = 4096B
+
+	my ($blocks,$softblocks,$hardblocks,undef,undef,$softinodes,$hardinodes,undef) = Quota::query($dev, $group->get_gid, 1);
+
+	# Set quota - only if database and filesystem are out of sync
+	unless( defined $softblocks and defined $hardblocks and defined $softinodes and defined $hardinodes
+	  and $softblocks == $hardblocks and $softinodes == $hardinodes
+	  and $hardblocks == $setblocks and $hardinodes == $setinodes) {
+
+		unless( Quota::setqlim($dev, $group->get_gid, $setblocks, $setblocks, $setinodes, $setinodes, 0, 1) ) {
+			Vhffs::Robots::vhffs_log( 'Set quota for group '.$group->get_groupname.' (gid '.$group->get_gid.') to '.$group->get_quota.' MB', $vhffs);
+		} else {
+			print 'Cannot set quota for group '.$group->get_groupname.' (gid '.$group->get_gid.'), reason: '.Quota::strerr()."\n";
+		}
+	}
+
+	# Get quota - only push changes if filesystem and database have different values
+	next unless defined $blocks;
+	my $used = ceil( ($blocks*1024)/1000000 );
+	next if $used == $group->get_quota_used;
+	$group->set_quota_used( $used );
+	$group->commit;
+	Vhffs::Robots::vhffs_log( 'Updated quota used for group '.$group->get_groupname.' (gid '.$group->get_gid.') to .'.$used.' MB', $vhffs);
+}
+
+Vhffs::Robots::unlock( $vhffs , 'quotagroup' );
+
+exit 0;

Deleted: trunk/vhffs-robots/src/group_setquota.pl
===================================================================
--- trunk/vhffs-robots/src/group_setquota.pl	2012-02-18 01:29:44 UTC (rev 2015)
+++ trunk/vhffs-robots/src/group_setquota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -1,64 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-require 5.004;
-use strict;
-use utf8;
-use POSIX;
-use locale;
-use Locale::gettext;
-use Quota;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Robots;
-use Vhffs::Group;
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "setquotagroup" );
-
-my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
-
-my $groups = Vhffs::Group::getall( $vhffs , Vhffs::Constants::ACTIVATED );
-foreach my $group ( @{$groups} )
-{
-	my $blocks = $group->get_quota * 1024;
-	my $inodes = $group->get_quota * 1126400 / 100;
-
-	if( Quota::setqlim($dev, $group->get_gid, $blocks, $blocks, $inodes, $inodes, 0, 1) )
-	{
-		printf("Cannot update quota for group %s (gid  %d), reason: %s\n", $group->get_groupname, $group->get_gid, Quota::strerr);
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "setquotagroup" );
-
-exit 0;

Modified: trunk/vhffs-robots/src/repository_quota.pl
===================================================================
--- trunk/vhffs-robots/src/repository_quota.pl	2012-02-18 01:29:44 UTC (rev 2015)
+++ trunk/vhffs-robots/src/repository_quota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -63,9 +63,9 @@
 	  and $hardblocks == $setblocks and $hardinodes == $setinodes) {
 
 		unless( Quota::setqlim($dev, $repo->get_owner_gid, $setblocks, $setblocks, $setinodes, $setinodes, 0, 1) ) {
-			Vhffs::Robots::vhffs_log( sprintf( 'Updated quota for repository %s to %d MB', $repo->get_name, $repo->get_quota ), $vhffs);
+			Vhffs::Robots::vhffs_log( 'Set quota for repository '.$repo->get_name.' (gid '.$repo->get_owner_gid.') to '.$repo->get_quota.' MB', $vhffs);
 		} else {
-			print 'Cannot update quota for repository '.$repo->get_name.', reason: '.Quota::strerr()."\n";
+			print 'Cannot set quota for repository '.$repo->get_name.' (gid '.$repo->get_owner_gid.'), reason: '.Quota::strerr()."\n";
 		}
 	}
 
@@ -75,7 +75,7 @@
 	next if $used == $repo->get_quota_used;
 	$repo->set_quota_used( $used );
 	$repo->commit;
-	Vhffs::Robots::vhffs_log( sprintf( 'Updated quota used for repository %s to %d MB', $repo->get_name, $used ), $vhffs);
+	Vhffs::Robots::vhffs_log( 'Updated quota used for repository '.$repo->get_name.' (gid '.$repo->get_owner_gid.') to '.$used.' MB', $vhffs);
 }
 
 # Give no space for groups without download repository
@@ -91,7 +91,7 @@
 	  and $softinodes == 1 and $hardinodes == 0;
 
 	if( Quota::setqlim($dev, $group->get_gid, 1, 0, 1, 0, 0, 1) ) {
-		print 'Cannot set quota to zero for group '.$group->get_groupname.', reason: '.Quota::strerr()."\n";
+		print 'Cannot set quota to zero for group '.$group->get_groupname.' (gid '.$group->get_gid.'), reason: '.Quota::strerr()."\n";
 	}
 }
 
@@ -105,7 +105,7 @@
 	  and $softinodes == 1 and $hardinodes == 0;
 
 	if( Quota::setqlim($dev, $user->get_gid, 1, 0, 1, 0, 0, 1) ) {
-		print 'Cannot set quota to zero for user '.$user->get_username.', reason: '.Quota::strerr()."\n";
+		print 'Cannot set quota to zero for user '.$user->get_username.' (gid '.$user->get_gid.'), reason: '.Quota::strerr()."\n";
 	}
 }
 

Deleted: trunk/vhffs-robots/src/user_getquota.pl
===================================================================
--- trunk/vhffs-robots/src/user_getquota.pl	2012-02-18 01:29:44 UTC (rev 2015)
+++ trunk/vhffs-robots/src/user_getquota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -1,69 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-require 5.004;
-use strict;
-use utf8;
-use POSIX;
-use locale;
-use Locale::gettext;
-use Quota;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Robots;
-use Vhffs::Group;
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "getquotauser" );
-
-my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
-
-my $users = Vhffs::User::getall( $vhffs , Vhffs::Constants::ACTIVATED );
-foreach my $user ( @$users )  {
-
-	my $group = $user->get_group;
-	(my $blocks,undef,undef,undef,undef,undef,undef,undef) = Quota::query($dev, $group->get_gid, 1);
-
-	if(defined($blocks))  {
-		my $used = ($blocks + 1024 - ($blocks % 1024)) / 1024;
-		if($group->get_quota_used() != $used)  {
-			$group->set_quota_used( $used );
-			if( $group->commit > 0 )  {
-    				Vhffs::Robots::vhffs_log( sprintf( "Update quota used for user %s set %s" , $user->get_username , $used ) , $vhffs);
-			}
-		}   
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "getquotauser" );
-
-exit 0;

Copied: trunk/vhffs-robots/src/user_quota.pl (from rev 2012, trunk/vhffs-robots/src/user_getquota.pl)
===================================================================
--- trunk/vhffs-robots/src/user_quota.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/user_quota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -0,0 +1,81 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+require 5.004;
+use strict;
+use utf8;
+use POSIX;
+use locale;
+use Locale::gettext;
+use Quota;
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Main;
+use Vhffs::Robots;
+use Vhffs::Group;
+
+my $vhffs = init Vhffs::Main;
+
+Vhffs::Robots::lock( $vhffs, 'quotauser' );
+
+my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
+
+my $users = Vhffs::User::getall( $vhffs , Vhffs::Constants::ACTIVATED );
+foreach my $user ( @$users ) {
+	my $group = $user->get_group;
+	my $setblocks = ceil( ($group->get_quota*1000000)/1024 );  # Filesystem quota block = 1024B
+	my $setinodes = ceil( ($group->get_quota*1000000)/4096 );  # Filesystem block = 4096B
+
+	my ($blocks,$softblocks,$hardblocks,undef,undef,$softinodes,$hardinodes,undef) = Quota::query($dev, $group->get_gid, 1);
+
+	# Set quota - only if database and filesystem are out of sync
+	unless( defined $softblocks and defined $hardblocks and defined $softinodes and defined $hardinodes
+	  and $softblocks == $hardblocks and $softinodes == $hardinodes
+	  and $hardblocks == $setblocks and $hardinodes == $setinodes) {
+
+		unless( Quota::setqlim($dev, $group->get_gid, $setblocks, $setblocks, $setinodes, $setinodes, 0, 1) ) {
+			Vhffs::Robots::vhffs_log( 'Set quota for user '.$user->get_username.' (gid '.$group->get_gid.') to '.$group->get_quota.' MB', $vhffs);
+		} else {
+			print 'Cannot set quota for user '.$user->get_username.' (gid '.$group->get_gid.'), reason: '.Quota::strerr()."\n";
+		}
+	}
+
+	# Get quota - only push changes if filesystem and database have different values
+	next unless defined $blocks;
+	my $used = ceil( ($blocks*1024)/1000000 );
+	next if $used == $group->get_quota_used;
+	$group->set_quota_used( $used );
+	$group->commit;
+	Vhffs::Robots::vhffs_log( 'Updated quota used for user '.$user->get_username.' (gid '.$group->get_gid.') to .'.$used.' MB', $vhffs);
+}
+
+Vhffs::Robots::unlock( $vhffs, 'quotauser' );
+
+exit 0;

Deleted: trunk/vhffs-robots/src/user_setquota.pl
===================================================================
--- trunk/vhffs-robots/src/user_setquota.pl	2012-02-18 01:29:44 UTC (rev 2015)
+++ trunk/vhffs-robots/src/user_setquota.pl	2012-02-18 02:18:53 UTC (rev 2016)
@@ -1,65 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-require 5.004;
-use strict;
-use utf8;
-use POSIX;
-use locale;
-use Locale::gettext;
-use Quota;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Robots;
-use Vhffs::Group;
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "setquotauser" );
-
-my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
-
-my $users = Vhffs::User::getall( $vhffs , Vhffs::Constants::ACTIVATED );
-foreach my $user ( @{$users} )
-{
-	my $group = $user->get_group;
-	my $blocks = $group->get_quota * 1024;
-	my $inodes = $group->get_quota * 1126400 / 100;
-
-	if( Quota::setqlim($dev, $group->get_gid, $blocks, $blocks, $inodes, $inodes, 0, 1) )
-	{
-		printf("Cannot update quota for user %s (gid  %d), reason: %s\n", $user->get_username, $group->get_gid, Quota::strerr);
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "setquotauser" );
-
-exit 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/