ISPConfig quota soft/hard limit

Discussion in 'Tips/Tricks/Mods' started by zion, Dec 7, 2013.

  1. zion

    zion New Member

    Hi all!

    I'v searching for a while but I didn't find information about how does ISPConfig handles quota hard limit.
    My situations is:
    1st
    Sites -> Website -> Domain -> Harddisk Quota: 10MB
    Sites -> Statistics -> Website harddisk quota: Soft limit:10MB; Hard limit: 11MB
    2nd
    Sites -> Website -> Domain -> Harddisk Quota: 100MB
    Sites -> Statistics -> Website harddisk quota: Soft limit:100MB; Hard limit: 101MB

    Where comes this +1MB to hard limit?
    Is it possible to setup quota without hard limit from ISPConfig, or I have to do it manualy every single time with 'edquota -u webXX'?

    Thank you in advance.
     
  2. zion

    zion New Member

    I returned to this question, because I want to set hard limit to 0.

    I'v found two related plugins. The first is:
    /usr/local/ispconfig/server/plugins-available/apache2_plugin.inc.php
    with code for quota:
    PHP:
    // Set the quota for the user, but only for vhosts, not vhostsubdomains
    if($username != '' && $app->system->is_user($username) && $data['new']['type'] == 'vhost') {
      if(
    $data['new']['hd_quota'] > 0) {
        
    $blocks_soft $data['new']['hd_quota'] * 1024;
        
    $blocks_hard $blocks_soft 1024;
      } else {
        
    $blocks_soft $blocks_hard 0;
      }
      
    exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null");
      
    exec('setquota -T -u '.$username.' 604800 604800 -a &> /dev/null');
    }
    So I'v created a custom plugin to change $blocks_hard to 0.
    There was a problem when I tried to use "$data['new']['type'] == 'vhost'" in if() because when I changed Harddisk Quota of the site I saw these things in $data array:
    PHP:
    [old] => Array
      (
        [
    domain_id] => 220
        
    ...
        [
    type] => vhost
        
    [parent_domain_id] => 0
        
    ...
    [new] => Array
      (
        [
    domain_id] => 220
        
    ...
        [
    type] => vhostsubdomain
        
    [parent_domain_id] => 0
        
    ...
    Which is really strange for me. How can type changed from vhost to vhostsubdomain?
    So now I use $data["new"]["parent_domain_id"] == "0" in if() instead of checking "type".

    The second plugin is:
    /usr/local/ispconfig/server/plugins-available/cron_plugin.inc.php
    So my next question is that when will cron_plugin.inc.php run? Do I have to create a custom plugin for cron_plugin too, if I want to keep hard limit 0?

    Thank you in advance.
     
  3. zion

    zion New Member

    I'v found answers to my questions, and modified my custom plugin.
    I share it with the others, it somebody will have the same problem:

    PHP:
            if ($data["new"]["parent_domain_id"] == "0") {
              if(
    $username != '' && $app->system->is_user($username)) {
                if(
    $data['new']['hd_quota'] > 0) {
                  
    $blocks_soft $data['new']['hd_quota'] * 1024;
                  
    $blocks_hard 0;
                }
                else {
                  
    $blocks_soft $blocks_hard 0;
                }
              }
            }
            else {
              
    $parent_domain $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `hd_quota` FROM `web_domain` WHERE `domain_id` = ".intval($data["new"]["parent_domain_id"]));
              
    $username escapeshellcmd($parent_domain["system_user"]);
              if(
    $username != '' && $app->system->is_user($username)) {
                if(
    $parent_domain["hd_quota"] > 0){
                  
    $blocks_soft $parent_domain["hd_quota"] * 1024;
                  
    $blocks_hard 0;
                }
                else {
                  
    $blocks_soft $blocks_hard 0;
                }
              }
            }
            
    exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null");
            
    exec('setquota -T -u '.$username.' 2592000 2592000 -a &> /dev/null');
        }
     

Share This Page