@@ -123,18 +123,37 @@ function update($event_name, $data) {
123123 exec ("useradd -d " .escapeshellcmd ($ parent_domain ["document_root " ])." -g $ groupname $ username -s /bin/false " );
124124 $ app ->log ("Adding the user: $ username " , LOGLEVEL_DEBUG );
125125 }
126-
127- // Set the quota for the user
128- if ($ username != '' && $ app ->system ->is_user ($ username )) {
129- if ($ parent_domain ["hd_quota " ] > 0 ){
130- $ blocks_soft = $ parent_domain ["hd_quota " ] * 1024 ;
131- $ blocks_hard = $ blocks_soft + 1024 ;
132- } else {
133- $ blocks_soft = $ blocks_hard = 0 ;
134- }
135- exec ("setquota -u $ username $ blocks_soft $ blocks_hard 0 0 -a &> /dev/null " );
136- exec ("setquota -T -u $ username 604800 604800 -a &> /dev/null " );
137- }
126+
127+ // Set the quota for the user
128+ if ($ username != '' && $ app ->system ->is_user ($ username )) {
129+ if ($ parent_domain ['hd_quota ' ] > 0 ) {
130+ $ blocks_soft = $ parent_domain ['hd_quota ' ] * 1024 ;
131+ $ mb_soft = $ parent_domain ['hd_quota ' ];
132+ $ blocks_hard = $ blocks_soft + 1024 ;
133+ $ mb_hard = $ mb_soft + 1 ;
134+ } else {
135+ $ mb_soft = $ mb_hard = $ blocks_soft = $ blocks_hard = 0 ;
136+ }
137+
138+ // get the primitive folder for document_root and the filesystem, will need it later.
139+ $ df_output =exec ("df -T $ document_root|awk 'END{print \$2, \$NF}' " );
140+ $ file_system = explode (" " , $ df_output )[0 ];
141+ $ primitive_root = explode (" " , $ df_output )[1 ];
142+
143+ if ( $ file_system , array ('ext2 ' ,'ext3 ' ,'ext4 ' ) ) {
144+ exec ('setquota -u ' . $ username . ' ' . $ blocks_soft . ' ' . $ blocks_hard . ' 0 0 -a &> /dev/null ' );
145+ exec ('setquota -T -u ' .$ username .' 604800 604800 -a &> /dev/null ' );
146+ } elseif ($ file_system == 'xfs ' ) {
147+
148+ exec ("xfs_quota -x -c 'limit -g bsoft= $ mb_soft " . 'm ' . " bhard= $ mb_hard " . 'm ' . " $ username' $ primitive_root " );
149+
150+ // xfs only supports timers globally, not per user.
151+ exec ("xfs_quota -x -c 'timer -bir -i 604800' " );
152+
153+ unset($ project_uid , $ username_position , $ xfs_projects );
154+ unset($ primitive_root , $ df_output , $ mb_hard , $ mb_soft );
155+ }
156+ }
138157
139158 //TODO : change this when distribution information has been integrated into server record
140159 //* Gentoo requires a user to be part of the crontab group.
0 commit comments