This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  3a9747935eabc4940274c2b74b547023aff38123 (commit)
       via  4953ca884a05c29e85d9daa8691368bba85c7828 (commit)
       via  38cb9fecf2469f6963c8e29134f5eccafd9301fe (commit)
       via  1b708d56646f3d45a7f46a134935c1d569eceef9 (commit)
      from  3cf7322d4b1f78a3b32adf2c515138f027f3da54 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=3a9747935eabc4940274c2b74b547023aff38123

commit 3a9747935eabc4940274c2b74b547023aff38123
Author: Franck Villaume <[email protected]>
Date:   Sun Jul 7 16:04:15 2019 +0200

    quota_management: enabling is different per filesystem type...

diff --git a/src/plugins/quota_management/bin/install.sh 
b/src/plugins/quota_management/bin/install.sh
index 4426736..8cdf682 100755
--- a/src/plugins/quota_management/bin/install.sh
+++ b/src/plugins/quota_management/bin/install.sh
@@ -3,23 +3,36 @@
 
 source $(forge_get_config source_path)/post-install.d/common/service.inc
 
-
 case "$1" in
        configure)
-               
                mountpointtocheck="$(forge_get_config homedir_prefix) 
$(forge_get_config groupdir_prefix) $(forge_get_config chroot) 
$(forge_get_config data_path)"
                for each in $mountpointtocheck; do
-                       echo "Checking mount option: usrquota & grpquota on 
$each"
                        if [ -d $each ]; then
                                mountpoint=$(df -P $each | tail -1 | awk 
'{print $6}')
-                               mountoptions=$(mount | grep "$mountpoint " | 
grep "usrquota" | grep "grpquota")
-                               if [ -z $mountoptions ];then
-                                       echo "Enabling usrquota & grpquota on 
$mountpoint"
-                                       #add option in fstab
-                                       mount -o remount,usrquota,grpquota 
$mountpoint
-                               else
-                                       echo "usrquota & grpquota already 
enabled on $mountpoint"
-                               fi
+                               mountfilesystem=$(mount | grep "$mountpoint " | 
awk '{print $5}')
+                               case $mountfilesystem in
+                                       'xfs')
+                                               mountoptions=$(mount | grep 
"$mountpoint " | grep "uquota" | grep "gquota")
+                                               if [ -z $mountoptions ]; then
+                                                       echo "Enabling uquota & 
gquota on $mountpoint"
+                                                       #requires boot 
changes!!!
+                                               else
+                                                       echo "uquota & pquota 
already enabled on $mountpoint"
+                                               fi
+                                               ;;
+                                       'ext4')
+                                       'ext3')
+                                               mountoptions=$(mount | grep 
"$mountpoint " | grep "usrquota" | grep "grpquota")
+                                               if [ -z $mountoptions ]; then
+                                                       echo "Enabling usrquota 
& grpquota on $mountpoint"
+                                                       #add option in fstab
+                                                       mount -o 
remount,usrquota,grpquota $mountpoint
+                                               else
+                                                       echo "usrquota & 
grpquota already enabled on $mountpoint"
+                                               fi
+                                               ;;
+                               esac
+
                        fi
                        #quotaon -guvp -a
                done

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=4953ca884a05c29e85d9daa8691368bba85c7828

commit 4953ca884a05c29e85d9daa8691368bba85c7828
Author: Franck Villaume <[email protected]>
Date:   Sun Jul 7 15:14:58 2019 +0200

    quota_management: remove obsolete INSTALL file, fix PHP, add post-install 
script

diff --git a/src/plugins/quota_management/INSTALL 
b/src/plugins/quota_management/INSTALL
deleted file mode 100644
index ef0b100..0000000
--- a/src/plugins/quota_management/INSTALL
+++ /dev/null
@@ -1,5 +0,0 @@
-edit cron
-
-0 * * * * root [ -x @PLUGINS_PATH@/quota_management/cronjobs/quota_update.pl ] 
&& @PLUGINS_PATH@/quota_management/cronjobs/quota_update.pl > /dev/null 2>&1
-
-
diff --git a/src/plugins/quota_management/bin/install.sh 
b/src/plugins/quota_management/bin/install.sh
new file mode 100755
index 0000000..4426736
--- /dev/null
+++ b/src/plugins/quota_management/bin/install.sh
@@ -0,0 +1,37 @@
+#!/bin/bash -e
+# Quota Management post-install
+
+source $(forge_get_config source_path)/post-install.d/common/service.inc
+
+
+case "$1" in
+       configure)
+               
+               mountpointtocheck="$(forge_get_config homedir_prefix) 
$(forge_get_config groupdir_prefix) $(forge_get_config chroot) 
$(forge_get_config data_path)"
+               for each in $mountpointtocheck; do
+                       echo "Checking mount option: usrquota & grpquota on 
$each"
+                       if [ -d $each ]; then
+                               mountpoint=$(df -P $each | tail -1 | awk 
'{print $6}')
+                               mountoptions=$(mount | grep "$mountpoint " | 
grep "usrquota" | grep "grpquota")
+                               if [ -z $mountoptions ];then
+                                       echo "Enabling usrquota & grpquota on 
$mountpoint"
+                                       #add option in fstab
+                                       mount -o remount,usrquota,grpquota 
$mountpoint
+                               else
+                                       echo "usrquota & grpquota already 
enabled on $mountpoint"
+                               fi
+                       fi
+                       #quotaon -guvp -a
+               done
+               
+               ;;
+       remove)
+               echo "Checking mount option: usrquota & grpquota"
+               echo "Disabling usrquota & grpquota"
+               #quotaoff -guvp -a
+               ;;
+       *)
+               echo "Usage: $0 {configure|remove}"
+               exit 1
+               ;;
+esac
diff --git 
a/src/plugins/quota_management/common/quota_managementPlugin.class.php 
b/src/plugins/quota_management/common/quota_managementPlugin.class.php
index 0c974f2..0de9fe0 100644
--- a/src/plugins/quota_management/common/quota_managementPlugin.class.php
+++ b/src/plugins/quota_management/common/quota_managementPlugin.class.php
@@ -75,7 +75,7 @@ to monitor disk and database usage per user, project.");
                $res = shell_exec($cmd);
                $a = explode("\t", $res);
                if (isset($a[1])) $size = $a[0];
-               return int($size);
+               return (int)$size;
        }
 
        function setDirSize($group_id, $dirtype, $dirsize) {
diff --git a/src/plugins/quota_management/view/quota.php 
b/src/plugins/quota_management/view/quota.php
index 2eebe08..4c6c115 100644
--- a/src/plugins/quota_management/view/quota.php
+++ b/src/plugins/quota_management/view/quota.php
@@ -168,7 +168,7 @@ if (db_numrows($res_db) > 0) {
 }
 foreach ($users as $u) {
        $user_id = $u["user_id"];
-       $dir = $ftp_dir .  $u["user_name"];
+       $dir = $ftp_dir.'/'.$u["user_name"];
        $size = $quota_management->get_dir_size($dir);
        $users["$user_id"]["disk_size"] += human_readable_bytes($size);
 }

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=38cb9fecf2469f6963c8e29134f5eccafd9301fe

commit 38cb9fecf2469f6963c8e29134f5eccafd9301fe
Author: Franck Villaume <[email protected]>
Date:   Sun Jul 7 14:54:02 2019 +0200

    add quota_management crontab entry

diff --git 
a/src/plugins/quota_management/etc/cron.d/fusionforge-plugin-quota_management 
b/src/plugins/quota_management/etc/cron.d/fusionforge-plugin-quota_management
new file mode 100644
index 0000000..147a6fb
--- /dev/null
+++ 
b/src/plugins/quota_management/etc/cron.d/fusionforge-plugin-quota_management
@@ -0,0 +1,7 @@
+#
+# Regular cron jobs for the plugin-quota_management package
+#
+PATH=@bindir@:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
+# Create wiki XML dumps every night
+55 2 * * * root forge_run_plugin_job quota_management quota_management.php 

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=1b708d56646f3d45a7f46a134935c1d569eceef9

commit 1b708d56646f3d45a7f46a134935c1d569eceef9
Author: Franck Villaume <[email protected]>
Date:   Sun Jul 7 14:33:26 2019 +0200

    quota_management: add packages, start compute via cronjob

diff --git a/src/debian/plugins b/src/debian/plugins
index 68d5832..37e4a0c 100644
--- a/src/debian/plugins
+++ b/src/debian/plugins
@@ -106,3 +106,6 @@ Depends: php-text-captcha
 
 Package: fusionforge-plugin-rest
 Depends:
+
+Package: fusionforge-plugin-quota_management
+Depends: quota
diff --git 
a/src/plugins/quota_management/common/quota_managementPlugin.class.php 
b/src/plugins/quota_management/common/quota_managementPlugin.class.php
index df59e7f..0c974f2 100644
--- a/src/plugins/quota_management/common/quota_managementPlugin.class.php
+++ b/src/plugins/quota_management/common/quota_managementPlugin.class.php
@@ -70,16 +70,27 @@ to monitor disk and database usage per user, project.");
        }
 
        function get_dir_size($dir) {
-               $size = "";
+               $size = 0;
                $cmd = "/usr/bin/du -bs $dir";
-               $res = shell_exec ($cmd);
+               $res = shell_exec($cmd);
                $a = explode("\t", $res);
                if (isset($a[1])) $size = $a[0];
-               return "$size";
+               return int($size);
+       }
+
+       function setDirSize($group_id, $dirtype, $dirsize) {
+               switch ($dirtype) {
+                       case 'home':
+                               $res = db_query_params('UPDATE 
plugin_quota_management SET home_usage = $1 WHERE group_id = $2', 
array($dirsize, $group_id));
+                               break;
+                       case 'ftp':
+                               $res = db_query_params('UPDATE 
plugin_quota_management SET ftp_usage = $1 WHERE group_id = $2', 
array($dirsize, $group_id));
+                               break;
+               }
        }
 
        function getDataArray($group_id) {
-               $res = db_query_params('select * from plugin_quota_management 
WHERE group_id = $1', array($group_id));
+               $res = db_query_params('SELECT * from plugin_quota_management 
WHERE group_id = $1', array($group_id));
                $this->data_array = db_fetch_array($res);
        }
 
diff --git a/src/plugins/quota_management/cronjobs/quota_management.php 
b/src/plugins/quota_management/cronjobs/quota_management.php
new file mode 100644
index 0000000..0fad34f
--- /dev/null
+++ b/src/plugins/quota_management/cronjobs/quota_management.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * quota_management cronjob
+ *
+ * Copyright 2019, Franck Villaume - Capgemini
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once dirname(__FILE__) . '/../../../www/env.inc.php';
+require_once $gfcommon.'include/pre.php';
+require_once $gfcommon.'include/cron_utils.php';
+require_once $gfcommon.'include/Group.class.php';
+
+$quota_management = plugin_get_object('quota_management');
+
+#compute the storage per project and per directory
+$activegroups = group_get_active_projects();
+if (forge_get_config('use_shell')) {
+       foreach ($activegroups as $activegroup) {
+               $ghome = forge_get_config('groupdir_prefix') . '/' . 
$activegroup->getUnixName();
+               if (is_dir($ghome)) {
+                       #compute Group Home dir
+                       $dirsize = $quota_management->get_dir_size($ghome);
+                       $quota_management->setDirSize($activegroup->getID(), 
'home', $dirsize);
+               }
+       }
+}
+
+if (forge_get_config('use_ftp')) {
+       foreach ($activegroups as $activegroup) {
+               $ftphome = forge_get_config('ftp_upload_dir') . '/' . 
$activegroup->getUnixName();
+               if ($activegroup->usesFTP() && is_dir($ftphome)) {
+                       #compute FTP dir
+                       $dirsize = $quota_management->get_dir_size($ftphome);
+                       $quota_management->setDirSize($activegroup->getID(), 
'ftp', $dirsize);
+               }
+       }
+}
+
+plugin_hook('quota_compute', array($activegroups));
diff --git a/src/rpm/plugins b/src/rpm/plugins
index 496af05..6d5c572 100644
--- a/src/rpm/plugins
+++ b/src/rpm/plugins
@@ -101,3 +101,6 @@ Requires: php-pear-Text-CAPTCHA
 
 %package plugin-rest
 Requires:
+
+%package quota_management
+Requires: quota

-----------------------------------------------------------------------

Summary of changes:
 src/debian/plugins                                 |  3 ++
 src/plugins/quota_management/INSTALL               |  5 --
 src/plugins/quota_management/bin/install.sh        | 50 +++++++++++++++++++
 .../common/quota_managementPlugin.class.php        | 19 ++++++--
 .../quota_management/cronjobs/quota_management.php | 56 ++++++++++++++++++++++
 .../etc/cron.d/fusionforge-plugin-quota_management |  7 +++
 src/plugins/quota_management/view/quota.php        |  2 +-
 src/rpm/plugins                                    |  3 ++
 8 files changed, 135 insertions(+), 10 deletions(-)
 delete mode 100644 src/plugins/quota_management/INSTALL
 create mode 100755 src/plugins/quota_management/bin/install.sh
 create mode 100644 src/plugins/quota_management/cronjobs/quota_management.php
 create mode 100644 
src/plugins/quota_management/etc/cron.d/fusionforge-plugin-quota_management


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to