3 * FusionForge cron job utilities
5 * Copyright 2003, GForge, LLC
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 // This key id# is important - do not change or renumber
30 $cron_arr[0]='unused';
31 $cron_arr[1]='calculate_user_metric.php';
32 $cron_arr[2]='check_stale_tracker_items.php';
33 $cron_arr[3]='db_project_sums.php';
34 $cron_arr[4]='db_stats_agg.php';
35 $cron_arr[5]='db_trove_maint.php';
36 $cron_arr[6]='massmail.php';
37 $cron_arr[7]='project_cleanup.php';
38 $cron_arr[8]='project_weekly_metric.php';
39 $cron_arr[9]='rating_stats.php';
40 $cron_arr[10]='rotate_activity.php';
41 $cron_arr[11]='site_stats.php';
42 $cron_arr[12]='vacuum.php';
43 $cron_arr[13]='cvs.php';
44 $cron_arr[14]='history_parse.php';
45 $cron_arr[15]='ssh_create.php';
46 $cron_arr[16]='usergroup.php';
47 $cron_arr[17]='mailaliases.php';
48 $cron_arr[18]='mailing_lists_create.php';
49 $cron_arr[19]='tarballs.php';
50 $cron_arr[20]='reporting_cron.php';
51 $cron_arr[21]='create_svn.php';
52 $cron_arr[22]='daily_task_email.php';
53 $cron_arr[23]='backup_site.php';
54 $cron_arr[24]='svn-stats.php';
55 $cron_arr[25]='homedirs.php';
56 $cron_arr[26]='update_users.php';
58 function cron_entry($job,$output) {
59 $sql='INSERT INTO cron_history (rundate,job,output)
60 values ($1, $2, $3)' ;
61 return db_query_params ($sql,
62 array (time(), $job, $output));
65 function cron_debug($string) {
72 function checkChroot() {
74 if(forge_get_config('chroot') != '' && is_dir(forge_get_config('chroot'))) {
80 function chrootPath($path) {
83 $path = forge_get_config('chroot').$path;
88 function chrootCommand($command) {
91 $command = 'chroot '.forge_get_config('chroot').' '.$command;
97 // Create lock via semaphore so long running jobs don't overlap
100 // $name - Name of cron job to use in the lock file name
102 function cron_create_lock($name) {
103 global $cron_utils_sem ;
104 if (! $cron_utils_sem[$name]) {
105 $token = ftok ($name, 'g');
106 $cron_utils_sem[$name] = sem_get ($token, 1, 0600, 0) ;
108 return sem_acquire ($cron_utils_sem[$name]);
112 // Delete lock created by cron_create_lock
115 // $name - Name of cron job to use in the lock file name
117 function cron_remove_lock($name) {
118 global $cron_utils_sem ;
119 if (! $cron_utils_sem[$name]) {
120 $token = ftok ($name, 'g');
121 $cron_utils_sem[$name] = sem_get ($token, 1, 0600, 0) ;
123 return sem_release ($cron_utils_sem[$name]);
128 // c-file-style: "bsd"