@@ -159,7 +159,6 @@ function delete($event_name,$data) {
159159 $ client_id = intval ($ client ["client_id " ]);
160160 unset($ client );
161161
162- /** TODO remove deleted record **/
163162 $ this ->parent_domain = $ parent_domain ;
164163 $ this ->_write_crontab ();
165164 }
@@ -174,7 +173,13 @@ function _write_crontab() {
174173
175174 //* try to find customer's mail address
176175
176+ /** TODO: add possibility for client to choose mail notification! **/
177177 $ cron_content = "MAILTO='' \n\n" ;
178+ $ chr_cron_content = "MAILTO='' \n\n" ;
179+ $ chr_cron_content .= "SHELL='/usr/sbin/jk_chrootsh' \n\n" ;
180+
181+ $ cmd_count = 0 ;
182+ $ chr_cmd_count = 0 ;
178183
179184 //* read all active cron jobs from database and write them to file
180185 $ cron_jobs = $ app ->db ->queryAllRecords ("SELECT `run_min`, `run_hour`, `run_mday`, `run_month`, `run_wday`, `command`, `type` FROM `cron` WHERE `parent_domain_id` = " .intval ($ this ->parent_domain ["domain_id " ]) . " AND `active` = 'y' " );
@@ -196,14 +201,35 @@ function _write_crontab() {
196201 if (substr ($ job ['command ' ], 0 , 1 ) != "/ " ) $ command .= $ this ->parent_domain ['document_root ' ];
197202 $ command .= $ job ['command ' ];
198203 }
199- $ cron_content .= $ command . "\n" ;
204+
205+ if ($ job ['type ' ] == 'chrooted ' ) {
206+ $ chr_cron_content .= $ command . "\n" ;
207+ $ chr_cmd_count ++;
208+ } else {
209+ $ cron_content .= $ command . "\n" ;
210+ $ cmd_count ++;
211+ }
200212 }
201213 }
202214
203215 $ cron_file = escapeshellcmd ($ cron_config ["crontab_dir " ].'/ispc_ ' .$ this ->parent_domain ["system_user " ]);
204- file_put_contents ($ cron_file , $ cron_content );
216+ if ($ cmd_count > 0 ) {
217+ file_put_contents ($ cron_file , $ cron_content );
218+ $ app ->log ("Wrote Cron file $ cron_file with content: \n$ cron_content " ,LOGLEVEL_DEBUG );
219+ } else {
220+ @unlink ($ cron_file );
221+ $ app ->log ("Deleted Cron file $ cron_file " ,LOGLEVEL_DEBUG );
222+ }
223+
224+ $ cron_file = escapeshellcmd ($ cron_config ["crontab_dir " ].'/ispc_chrooted_ ' .$ this ->parent_domain ["system_user " ]);
225+ if ($ chr_cmd_count > 0 ) {
226+ file_put_contents ($ cron_file , $ chr_cron_content );
227+ $ app ->log ("Wrote Cron file $ cron_file with content: \n$ chr_cron_content " ,LOGLEVEL_DEBUG );
228+ } else {
229+ @unlink ($ cron_file );
230+ $ app ->log ("Deleted Cron file $ cron_file " ,LOGLEVEL_DEBUG );
231+ }
205232
206- $ app ->log ("Wrote Cron file $ cron_file with content: \n$ cron_content " ,LOGLEVEL_DEBUG );
207233 return 0 ;
208234 }
209235
0 commit comments