4 * Copyright 2010, Olaf Lenz
5 * Copyright 2011, Roland Mas
6 * Copyright 2016, Franck Villaume
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 by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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 this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * This script will automatically create MoinMoin instances for
27 * projects that do not yet have them.
28 * It is intended to be started in a cronjob.
31 require_once (dirname(__FILE__) . '/../../../www/env.inc.php');
32 require_once $gfcommon.'include/pre.php';
33 require_once $gfcommon.'include/cron_utils.php';
35 $wikidata = forge_get_config('wiki_data_path', 'moinmoin');
36 $wsgi_user = forge_get_config('wsgi_user', '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 $wsgi_user: $project_dir");
61 $template = forge_get_config('config_path') . "/plugins/moinmoin/PROJECT_NAME.py.tmpl";
62 system('(echo "# Automatically generated on `LANG=C date` from '.$template.'";'
63 . 'echo "# DO NOT EDIT";'
64 . "sed s/@PROJECT_NAME@/$project/ < $template) > $wikidata/$project.py");
71 // Using restart rather than reload, to avoid late WSGI socket changes during test suite
77 // c-file-style: "bsd"