4 * Copyright 2010, Olaf Lenz
5 * Copyright 2011, Roland Mas
7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 /** This script will automatically create MoinMoin instances for
25 projects that do not yet have them.
27 It is intended to be started in a cronjob.
30 require_once (dirname(__FILE__) . '/../../../www/env.inc.php');
31 require_once $gfcommon.'include/pre.php';
32 require_once $gfcommon.'include/cron_utils.php';
34 $data_path = forge_get_config('data_path');
35 $src_path = forge_get_config('src_path', 'moinmoin');
36 $wikidata = forge_get_config('wiki_data_path', 'moinmoin');
38 // Get all projects that use the mediawiki plugin
39 $project_res = db_query_params ("SELECT g.unix_group_name from groups g, group_plugin gp, plugins p where g.group_id = gp.group_id and gp.plugin_id = p.plugin_id and p.plugin_name = $1;", array("moinmoin"));
41 $err = "Error: Database Query Failed: ".db_error();
49 // Loop over all projects that use the plugin
50 while ( $row = db_fetch_array($project_res) ) {
51 $project = $row['unix_group_name'];
52 $project_dir = "$wikidata/$project";
53 cron_debug("Checking $project...");
55 // Create the project directory if necessary
56 if (!is_dir($project_dir)) {
57 cron_debug(" Creating project dir $project_dir.");
58 mkdir($project_dir, 0755, true);
59 system("cp -r /usr/share/moin/data /usr/share/moin/underlay $project_dir/");
60 system("chown -R gforge:gforge $project_dir");
61 $f = fopen ("$wikidata/$project.py","w");
62 fwrite ($f, "from farmconfig import FarmConfig
63 class Config(FarmConfig):
64 sitename = u'$project'
65 interwikiname = u'$project'
66 page_front_page = u'FrontPage'
68 data_dir = '$project_dir/data'
69 data_underlay_dir = '$project_dir/underlay'
78 system("invoke-rc.d apache2 reload");
83 // c-file-style: "bsd"