3 * FusionForge cron job utilities
5 * Copyright 2003, GForge, LLC
6 * Copyright 2009, Roland Mas
7 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 // This key id# is important - do not change or renumber
29 $cron_arr[0]='unused';
30 $cron_arr[1]='calculate_user_metric.php';
31 $cron_arr[2]='check_stale_tracker_items.php';
32 $cron_arr[3]='db_project_sums.php';
33 $cron_arr[4]='db_stats_agg.php';
34 $cron_arr[5]='db_trove_maint.php';
35 $cron_arr[6]='massmail.php';
36 $cron_arr[7]='project_cleanup.php';
37 $cron_arr[8]='project_weekly_metric.php';
38 $cron_arr[9]='rating_stats.php';
39 $cron_arr[10]='rotate_activity.php';
40 $cron_arr[11]='site_stats.php';
41 $cron_arr[12]='vacuum.php';
42 $cron_arr[13]='cvs.php';
43 $cron_arr[14]='history_parse.php';
44 $cron_arr[15]='ssh_create.php';
45 $cron_arr[16]='usergroup.php';
46 $cron_arr[17]='mailaliases.php';
47 $cron_arr[18]='mailing_lists_create.php';
48 $cron_arr[19]='tarballs.php';
49 $cron_arr[20]='reporting_cron.php';
50 $cron_arr[21]='create_svn.php';
51 $cron_arr[22]='daily_task_email.php';
52 $cron_arr[23]='backup_site.php';
53 $cron_arr[24]='svn-stats.php';
54 $cron_arr[25]='homedirs.php';
55 $cron_arr[26]='update_users.php';
56 $cron_arr[27]='create_scm_repos.php';
57 $cron_arr[28]='gather_scm_stats.php';
59 $cron_arr[901]='create_groups.php';
60 $cron_arr[902]='mailing_lists_index.php';
62 function cron_entry($job,$output) {
63 $sql='INSERT INTO cron_history (rundate,job,output)
64 values ($1, $2, $3)' ;
65 return db_query_params ($sql,
66 array (time(), $job, $output));
69 function cron_debug($string) {
76 function checkChroot() {
78 if(forge_get_config('chroot') != '' && is_dir(forge_get_config('chroot'))) {
85 // Create lock via semaphore so long running jobs don't overlap
88 // $name - Name of cron job to use in the lock file name
90 function cron_create_lock($name) {
91 global $cron_utils_sem ;
92 if (! $cron_utils_sem[$name]) {
93 $token = ftok ($name, 'g');
94 $cron_utils_sem[$name] = sem_get ($token, 1, 0600, 0) ;
96 return sem_acquire ($cron_utils_sem[$name]);
100 // Delete lock created by cron_create_lock
103 // $name - Name of cron job to use in the lock file name
105 function cron_remove_lock($name) {
106 global $cron_utils_sem ;
107 if (! $cron_utils_sem[$name]) {
108 $token = ftok ($name, 'g');
109 $cron_utils_sem[$name] = sem_get ($token, 1, 0600, 0) ;
111 return sem_release ($cron_utils_sem[$name]);
116 // c-file-style: "bsd"