Okay folks, 

here's a little script for assisting wiki updates. 
It does not yet fix the database permissions, since I'm not yet 
shure how I like to pass the superuser login/passwd.
(suggestions welcomed)

cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux IT service - http://www.metux.de/
---------------------------------------------------------------------
 Please visit the OpenSource QM Taskforce:
        http://wiki.metux.de/public/OpenSource_QM_Taskforce
 Patches / Fixes for a lot dozens of packages in dozens of versions:
        http://patches.metux.de/
---------------------------------------------------------------------
#!/usr/bin/php
<?php
//
// Copyright 2006, Enrico Weigelt, metux IT service <[EMAIL PROTECTED]>
//
// This script may be redistributed under the terms of the GPL.
//

$WEBAPP="mediawiki";
$DBSUPERUSER_NAME="root";
$DBSUPERUSER_PASSWORD="pemnj92";

if (!$_SERVER{'argv'}[2])
    die ("update-wiki: <hostname> <version>");

$HOSTNAME=$_SERVER{'argv'}[1];
$VERSION=$_SERVER{'argv'}[2];
$WWWROOT="/var/www/$HOSTNAME/htdocs";
$MNTDIR="$WWWROOT/maintenance/";
$LOCALSETTINGS="$WWWROOT/LocalSettings.php";
$ADMINSETTINGS="$WWWROOT/AdminSettings.php";

if ([EMAIL PROTECTED]($LOCALSETTINGS,"r"))
    die ( "missing LocalSettings.php - you have to configure it first" );

if ([EMAIL PROTECTED]($ADMINSETTINGS,"r"))
{
    echo "missing AdminSettings.php ... creating it\n";
    define('MEDIAWIKI',1);
    require_once($LOCALSETTINGS);
    $fp_in=fopen($LOCALSETTINGS,"r");
    $fp_out=fopen($ADMINSETTINGS,"w");
    while (!feof($fp_in))
    {
        $line=fgets($fp_in,4096);
        if (trim($line)=='?>')
        {
            fputs($fp_out,'$wgDBadminuser="'.$wgDBuser."\";\n");
            fputs($fp_out,'$wgDBadminpassword="'.$wgDBpassword."\";\n");
            fputs($fp_out,"\n");
            fputs($fp_out,$line);
            while (!feof($fp_in))
                fputs($fp_out,fgets($fp_in,4096));
            $gotend = true;
        }
        else
            fputs($fp_out,$line);
    }
    if (!$gotend)
    {
        fputs($fp_out,'$wgDBadminuser="'.$wgDBuser."\";\n");
        fputs($fp_out,'$wgDBadminpassword="'.$wgDBpassword."\";\n");
    }
    fclose($fp_in);
    fclose($fp_out);
}    

print "Upgrading the webapp code (->webapp-config)\n";
if (passthru("webapp-config -U -h $HOSTNAME $WEBAPP $VERSION",$ret)||($ret==0))
    print "Okay\n";
else
    die ( "webapp-config failed: $ret\n");

print "Now calling the update script\n";
print "If it cannot do certain structure changes (ie. creating tables),\n";
print "you have to give full db access to the wiki user\n";
print "\n";

if (passthru("cd $MNTDIR && php update.php",$res)||($res==0))
    print "OKAY\n";
else
    die("ERROR\n");

Reply via email to