MigrateToMediaWiki

From T2B Wiki
Jump to navigation Jump to search

The plan of the migration

Here are the steps :

  • creation of a new Apache webserver called "mona" with Quattor
  • moving all the Trac wiki's to mona
  • conversion of the Trac wiki's to MediaWiki (thanks to a homebrewed script)
  • once everything is ready, switch to the new webserver in the DNS servers

Creation of the new webserver

It is a virtual machine with 60GB of disk size (see the hardware template hardware/machine/Virtual/virtual_kvm_mon for more details). The software configuration is done through the template config/t2b_docu_server.

Moving the Trac wiki's to the new webserver

For each wiki that was on the old mon server, create a new wiki on the new webserver with the trac-admin command. For example :

trac-admin /var/www/trac/t2b initenv

On the old webserver, you make a copy of each wiki to a nfs-shared directory. Going on with the previous example, it gives something like this :

trac-admin /var/www/trac/t2b hotcopy /userbackup/sgerard/trac_backup_20-08-2015/t2b

Now, going back to the new webserver, we can simply overwrite the content of /var/www/trac/t2b with the content of the back-up copy :

cp -a -p /userbackup/sgerard/trac_backup_20-08-2015/t2b /var/www/trac/

(Of course, it works because the nfs-share where the backup copy was done on the old server has been mounted on the new webserver thanks to Quattor ;-)

Conversion from Trac to MediaWiki

For each Trac wiki that you would like to migrate, you have to create a new empty MediaWiki. I will explain all the details below.

Create a new empty MediaWiki

Here are steps to create a wiki "test" :

mkdir /var/www/mediawiki199/test
chown apache:apache /var/www/mediawiki199/test
cd /var/www/mediawiki199/test
ln -s /usr/share/mediawiki199/* .
rm LocalSetting.php AdminSettings.php images mw-config
cp -a /usr/share/mediawiki199/mw-config .

Now, you have to open the URL of the wiki in your browser for the initialization. After you have filled in all the forms of the wizard, you arrive on page saying "Installation successful !", and that you can download the LocalSettings.php and copy it to the directory of your wiki. After it is copied, don't forget to adapt the permissions :

chown apache:apache LocalSettings.php
chmod 640 LocalSettings.php

After that, you can remove the mw-config directory because it is only necessary to run the wizard :

rm -rf mw-config

To enable image uploading, you need to do this in the directory of the wiki :

mkdir images
chmod 755 images
chown apache:apache images

And then, you need to add a few lines at the end of the LocalSetting.php config. file :

$wgUploadDirectory = "images";
$wgUploadPath = "$wgScriptPath/images";
$wgEnableUploads = true;

And that's it !

Conversion

Now, for each wiki, the next step is to export all the pages in txt format, convert them in MediaWiki format, and then import the converted pages in the corresponding MediaWiki. To avoid hours of tedious manual tasks, a script has been created, and it is available on our SVN "scripting" repository : http://mon.iihe.ac.be/repos/scripting/mon/convert_trac_to_mediawiki/. Here is an example showing how to use it :

  1. The following commands will create a blank new wiki :
    ssh mona
    svn co http://mon.iihe.ac.be/repos/scripting/mon/convert_trac_to_mediawiki
    cd convert_trac_to_mediawiki
    ./export_all_pages.pl /var/www/trac/t2b /var/www/mediawiki119/t2b
    
  2. Now you have to initialize the wiki. Go to the URL you have created :
    http://mona.iihe.ac.be/wiki/test
    

    and follow the instructions.

Access restriction to wiki pages

Anybody can read the pages, but to modify the content, you need to login. Login is done through SSL, meaning that your certificate will be asked, and if its DN contains "O=BEGRID" or "DC=cern", it is accepted and an account is automatically created. This account remains associated to your DN.

Now, the technical details : we use "Extension:SSL authentication" that is documented here. But to force the switch to HTTPS when clicking on "Log in", we had to add this in the httpd.conf :

RewriteCond %{REQUEST_URI} ^/wiki/t2b/index.php$
RewriteCond %{QUERY_STRING} ^title=Special:UserLogin
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteRule ^(.*)$ https://%{SERVER_NAME}/wiki/t2b/index.php/Main_Page [R]

Sources


Template:TracNotice