#!/usr/bin/php // // 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=$_SERVER{'argv'}[1]; $VERSION=$_SERVER{'argv'}[2]; $WWWROOT="/var/www/$HOSTNAME/htdocs"; $MNTDIR="$WWWROOT/maintenance/"; $LOCALSETTINGS="$WWWROOT/LocalSettings.php"; $ADMINSETTINGS="$WWWROOT/AdminSettings.php"; if (!@fopen($LOCALSETTINGS,"r")) die ( "missing LocalSettings.php - you have to configure it first" ); if (!@fopen($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");