Sunday, 27 April 2008

Backing and Restoring Mediawiki in Ubuntu

We are going to learn how to back up and restore our Mediawiki installed on a Ubuntu system.

To acomplish that we will execute some wiki maintenance commands.
These maintenance commands will be accesible after configuring AdminSettings.php file.

CONFIGURING AdminSettings.php FILE


AdminSettings.sample from the Mediawiki examples documentation will serve us as a model file to start.

We copy it into mediawiki configuration directory in /etc and assign the correct owner and permissions.
$sudo cp /usr/share/doc/mediawiki1.10/examples/AdminSettings.sample /etc/mediawiki1.10/AdminSettings.php
$sudo chown root:root /etc/mediawiki1.10/AdminSettings.php
$sudo chmod 600 /etc/mediawiki1.10/AdminSettings.php



Now we are going to edit AdminSettings.php file
$gksudo gedit /etc/mediawiki1.10/AdminSettings.php

Change these two variables using the parameters you used when creating the wiki database: e.g: wikiuser and its password.
$wgDBadminuser = 'DB user name'
$wgDBadminpassword = 'DB password'

Now that AdminSettings.php file is properly configured we are gonna back up and restore the wiki.


BACKING UP THE WIKI


dumpBackup.php command will back up our wiki:
$cd /var/lib/mediawiki1.10/maintenance
$sudo php dumpBackup.php --current > ~/foo_backup.xml

NOTE: --full option backups history of pages, not only last version as --current does.


RESTORING THE WIKI

Installing and Configuring Mediawiki on a Ubuntu Gutsy Desktop System

Mediawiki is the web based tool (wiki software) that Wikipedia uses to manage, store and serve its contents.

Mediawiki is written in PHP, and in this installation we will use MySQL as database management system (although it can be configured to use PostgreSQL)

Mediawiki is ditributed under the GNU GPL license.


INSTALLING MEDIAWIKI


First step is installing MySQL:
$sudo aptitude install mysql-admin mysql-server

It will ask you for MySQL root password. Then choose a secure password and type it.


Now we install Mediawiki itself:
$sudo aptitude install mediawiki

It will automatically check for apache and php dependencies.

Current mediawiki version is 1.10.


At installation I get this warning:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

There is some info in this thread at ubuntu forums.

To get rid of the error:
$gksudo gedit /etc/apache2/httpd.conf

httpd.conf file is usually empty, and then we add this line:
ServerName localhost

After saving the file we check if the error is gone executing this command:
$sudo apache2ctl restart


SETTING MEDIAWIKI URL ALIAS

Sunday, 30 March 2008

GNU/Linux SYSTEM DIRECTORIES and their FILESYSTEMS

Executing $ ls / lists the top level of the root filesystem tree. There appear directories like:
/dev, /etc, /proc, /sys, /var, /tmp and others.

In this article we are going to deal with directories that have special filesystems associated with them.


For a general view of the filesystem hierarchy we can visit the Filesystem Hierarchy Standard page.

FHS standard is a set of guidelines about where to place files and directories within UNIX based operating systems.


Check which filesystems are mounted


Two commands allow us to examine which filesystems and where are currently mounted in our system.

$ mount
or
$ cat /etc/mtab


Their response will be something like that:
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.22-14-generic/volatile type tmpfs (rw)
securityfs on /sys/kernel/security type securityfs (rw)


We are specially interested in /proc, /sys, /var/run, /var/lock, /dev, /dev/shm, /dev/pts, /sys/kernel/security




/proc directory

Wednesday, 26 March 2008

Reverse Engineering Python Code with PyNSource

PyNSource is a tool that allow us to obtain UML diagrams from python source code.

PyNSource Web Page


INSTALLING PyNSource ON AN UBUNTU GUTSY SYSTEM.

NOTE: You must have python already installed in your system. I assume 2.5 version.

$mkdir PyNSource
$cd PyNSource


Now we download the program and install it:
$wget http://www.atug.com/downloads/pynsource1.4c.zip
$unzip pynsource1.4c.zip
$sudo python setup.py install


We want to run the GUI so we need a graphical library:
$sudo aptitude install python2.5-wxgtk2.6

Current code does not work with version wxgtk2.6 so we need to update it:
$wget http://www.atug.com/andypatterns/code/pyNsourceGui1.4c-wx26.zip
$unzip pyNsourceGui1.4c-wx26.zip
$sudo cp pyNsourceGui-wx26.py /usr/lib/python2.5/site-packages/pynsource/


Finally we exec the GUI module
$python /usr/lib/python2.5/site-packages/pynsource/pyNsourceGui-wx26.py


This application presents some annoying bugs:

* There are problems when moving shapes on the screen. It does not refresh correctly.
* It is difficult to adjust page size when you try to print it.
* When you press right click button on the mouse to delete an object, usually it doesn't delete all the arrows that point to it, messing the schema.
* Saving and opening diagram feature is not implemented yet, so you cannot save temporary work.


Well, you know, this bugs are annoying, but it you dont like them, it is free software, so hack the code. :-)

Friday, 14 March 2008

GNU Readline Library Short Description

GNU Readline is a software library that provides a set of functions that allow users to edit command lines as they are typed in.

Every program that uses this library provides the same user command line interface improving consistency between applications.

It is part of the GNU Project and it is licensed under the GPL.

Current version is 5.2 and it is used in projects like bash.

There are two editing modes available: Emacs (default) and Vi

Readline library includes additional functions to maintain a list of previously-entered command lines.
Exec this command to obtain more info about this feature:
$help history


INSTALLATION

In Debian and Ubuntu this library is packed in readline-common package.
$sudo aptitude install readline-common

Once installed, you can access a complete documentation using info command:
$info rluserman


SHORT KEYSTROKE REMINDER

NOTATION:
C-k means while ctrl key is mantained pressed, depress 'k' key.
M-k means while "meta" key is pressed, depress 'k' key.

Usually "meta" refers to ALT key, but if you have no meta key you can use ESC key instead.


Emacs mode commmands:

Movement

C-b Move back the cursor one character.
C-f Move one character forward.
DEL or Backspace Delete the character placed left at the cursor.
C-d Delete the character underneath the cursor.
C-_ or C-x C-u Undo the last editing command.

C-a Move to the beginning of the line.
C-e Move to the end of the line.
M-f Move forward a word.
M-b Move backward a word.
C-l Clear the screen, reprinting the current line at the top.

Killing and yanking (cutting and pasting) commands

C-k Kill the text from the current cursor position to the end of the line.
M-d Kill from the cursor to the end of the current word.
M-DEL Kill from the cursor the start of the current word.
C-w Kill from the cursor to the previous whitespace.

After killing(cutting) text, we yank(paste) it back into the line.

C-y Yank the most recently killed text back into the buffer at the cursor.
M-y Rotate the kill-ring, and yank the new top. You can only do this if the prior command is C-y or M-y.

Searching commands

C-r Searchs backwards on the previous commands you typed.
C-s Perform a forward search from the command line history you are now.

Passing arguments to a command

e.g: M-2 3 C-d means delete next 23 characters on input line.



CONFIGURING THE LIBRARY

GNU Readline keybindings and more can be changed editing ~/.initrc or /etc/initrc files.


URLs
GNU Readline Official page
GNU Readline (Wikipedia)
Official online Readline documentation

Tuesday, 19 February 2008

Bash tips II

RETYPING A COMMAND YOU TYPED SEVERAL LINES BEFORE

Sometimes you have to type a command you typed before, but you don't want to write it again, or don't remember exactly what you wrote on your command prompt.
Solution is easy, we are gonna use reverse search!

Press the keys: ctrl+r and then type part of the command you want to retype.
NOTE:It is not necessary to write the beginning of the command, you can write whatever part you want for reverse search.

If reverse search has found a command but it is not the one you were searching for, type ctrl+r again till you find it, or write a better part of the command at search time.


Now we have found the command, we have two options:
- pressing enter, the command will be executed
- pressing tab key we will be able to edit this command at the bash prompt prior to its execution.


CHANGING INTO ANOTHER DIRECTORY but memorizing where we are now in order to return later easily

This is useful if you have long weird named paths.

We are now located at foo directory:
:/foo$pwd
/foo


We want to change into bar directory, instead of using cd command we use pushd
:/foo$pushd /bar

Now we are in /bar directory:
:/bar$pwd
/bar


In order to return to prior foo directory we only have to run popd command.
:/bar$popd

:foo$pwd
/foo


CHECKING FOR BAD BLOCKS IN A PARTITION

Sometimes we want to check the blocks of a hard disk we have just bought, or whatever...

We have two options:

  • First time, when creating the filesystem with '-c' option

    e.g: mkefs.ext3 -c -b 4096 -L foo /dev/sdb2


  • If the filesystem at this partition has been already created we can use badblocks command.

    NOTE: Read carefully badblocks man page, $man badblocks before doing anything potentially harmfull.

    e.g: sudo badblocks -v /dev/sdb2

Sunday, 2 September 2007

TVAnts on Ubuntu

TVAnts is a peer to peer program that allows you to share live streams instead of files.
Although these streams can contain any sort of media they are mostly used for watching live football matches and other events on PCs.


TVAnts pages:

www.tvants-ppstream.com
Official TVAnts page is written in chinese: tvants.com


Installing TVAnts:

Download TVAnts setup program: ( I have obtained this address from official TVAnts page.)
$wget http://88.191.73.231/~cali/tvants/TvantsSetup.exe

We need wine to run TVAnts setup program because it is a microsoft windows executable:
$sudo aptitude install wine       # if you have not already installed wine program.
$wine "TvantsSetup.exe"

It will install itself, and then we will be able to exec the program:
$wine ~/.wine/drive_c/Program\ Files/TVAnts/Tvants.exe
or
$wine 'C:\Program Files\TVAnts\Tvants.exe'


Watching TV:

You will need at least one server at server tab.
e.g: list.tvants.com

At search tab you will be able to search for hundreds of channels.
Select some and add them to channel tab.

NOTE: Do not worry about error messages related to windows media player, we will use mplayer.

You can watch the channel you have selected runing in the console:
$mplayer -framedrop mms://localhost:16900/1
Last "1" means first channel from your selected channels list.
NOTE: Whenever you add a new channel this number increases in one, even if you delete previous unused channels.


NOTE: TVAnts is a peer to peer system so you should open 16800 port on your box to share streams you are watching with other users.

NOTE: You can also watch the tv streams using vlc instead of mplayer.

Tuesday, 21 August 2007

GRID Computing

It looks fascinating!

Introduction to grid computing (IBM papers)

Sunday, 19 August 2007

BOINC Distributed Computing Projects

Donating spare CPU cycles to distributed computing projects.



Most of time your cpu load is well below under 100%.

You can check how many resources are you using right now, going to menu:
System --> Administration --> System Monitor

What about if this spare resources all over the world would be used by projects like curing diseases,
discover extraterrestrial inteligence, predice climate changes... ?

That is actually possible, here you have a list of projects you can participate:
http://boinc.berkeley.edu/projects.php


These are all distributed computing projects, based on BOINC platform.


Let's try this thing for real. First step will be installing BOINC:

BOINC - Debian and Ubuntu installation

$sudo aptitude update

$sudo aptitude install boinc-client boinc-manager

execute graphic boinc manager:
$boincmgr

you only have to follow wizard instructions.

NOTE: To join a project:
menu bar Tools -> Attach to project

NOTE: You will need konqueror browser to navigate the web from boincmgr.


Some info about interesting BOINC projects:

Roseta@home project: http://boinc.bakerlab.org/rosetta/

Rosetta@home needs your help to determine the 3-dimensional shapes of proteins in research that may ultimately lead to finding cures for some major human diseases. By running the Rosetta program on your computer while you don't need it you will help us speed up and extend our research in ways we couldn't possibly attempt without your help. You will also be helping our efforts at designing new proteins to fight diseases such as HIV, Malaria, Cancer, and Alzheimer's (See our Disease Related Research for more information). Please join us in our efforts! Rosetta@home is not for profit.


Climateprediction.net: http://climateprediction.net

Climateprediction.net is the largest experiment to try and produce a forecast of the climate in the 21st century. To do this, we need people around the world to give us time on their computers - time when they have their computers switched on, but are not using them to their full capacity.
[read more about the experiment]

Sunday, 12 August 2007

Zattoo on Ubuntu Feisty

Zattoo is a program that allows us to see streaming TV channels over Internet.

It is unfortunately closed source.


Let's go to official Zattoo web page: zattoo.com

Check on your language flag to see what channels are available to see at your zone.


Register to obtain zattoo program: http://zattoo.com/register

After registering, select linux and download zattoo deb file:
e.g: zattoo-2.2.10.6523-i386.deb

Now install the deb file:
$sudo dpkg -i zattoo-2.2.10.6523-i386.deb

I get dependency problems:
zattoo needs libgtkglext1 and libxul0d but those are not installed.

We install those required packages:
$sudo aptitude install libgtkglext1 libxul0d

Once dependencies are solved zattoo package configures automatically.
If that does not happen, then exec:
$sudo dpkg --configure zattoo

Download and install the Adobe Flash plugin from http://www.adobe.com if you have not it on your system yet.

run:
$zattoo_player

introduce your zattoo login (used when registering) and enjoy!

NOTE: To obtain new zattoo versions when they will be available, go to zattoo page, click on login word near country flags, and introduce your email and password.

NOTE: If you wanna know on which ports zattoo is listening, exec this command:
$sudo netstat -l -p -e | grep -i zattoo