Friday, June 23, 2006

ubuntu newbie tips

add a root user in ubuntu:
Hum, weird, no default root account seems to be created in ubuntu. The command to do so is:
sudo passwd root:
Then type your root password.
Now you can su like in any other distro (except debian maybe :)

Thursday, June 15, 2006

mailing list filter with procmail

See http://pm-doc.sourceforge.net/pm-tips.html section 11.0

An interesting mini FAQ lies there: http://laku19.adsl.netsonic.fi/%7Eera/procmail/mini-faq.html

This is actually a procmail module which do the job.
The procmail modules seems to be tackled there: http://pm-lib.sourceforge.net/
Go to the download page and fetch this from sourceforge.

In my case, I am just trying to filter majordomo mailings, and this simply work:

:0 : # Majordomo lists
* ^Sender: owner-\/[-a-zA-Z0-9_.]*
list.$MATCH.mbox

Monday, June 12, 2006

Search your own website with xapian's omega

Actually this HOWTO already exists :)
-> http://wiki.xapian.org/OmegaExample

Download and install omega and xapian from xapian.org. This is a regular autotooled software install:
(cd ; ./configure ; make ; su ; make install)

Then, basic doc is under omega-/doc/quickstart.txt.

Here is what worked for me:

I have put the omega files under my public_html.

mkdir -p ~/public_html/omega/var/log/omega
mkdir -p ~/public_html/omega/var/lib/omega/data
mkdir -p ~/public_html/omega/var/lib/omega/templates
mkdir p ~/public_html/omega/var/lib/omega/cdb
cp OMEGA_SRC_DIR/omega-0.9.6/templates/* ~/public_html/omega/var/lib/omega/templates/

chmod -R a+r ~/public_html/omega/var/lib/omega/templates/
chmod -R 755 ~/public_html/omega/

# Now we start the indexation:
omindex --db ~/public_html/omega/var/lib/omega/data/default --url http://FULLY_QUALIFIED_HOSTNAME/~bsergean/mailarchives ~bsergean/public_html/mailarchives

# Now we install the cgi and its config file
cp /usr/local/lib/omega/bin/omega ~/public_html/cgi-bin/omega.cgi
cat > ~/public_html/cgi-bin/omega.conf
database_dir /home/bsergean/public_html/omega/var/lib/omega/data
template_dir /home/bsergean/public_html/omega/var/lib/omega/templates
log_dir /home/bsergean/public_html/omega/var/log/omega
cdb_dir /home/bsergean/public_html/omega/var/lib/omega/cdb
Hit Control D now.

That's it !!

Now, go to http://FULLY_QUALIFIED_HOSTNAME/~bsergean/cgi-bin/omega.cgi
and make your search.

Archive your mailing lists

Using mhonarc:

First, urpmi it and its dependencies:

[root@flanders snapshots]# urpmi mhonarc
To satisfy dependencies, the following 6 packages are going to be installed (9 MB):
MHonArc-2.6.10-1mdk.noarch
perl-Jcode-0.86-2mdk.i586
perl-Unicode-Map-0.112-4mdk.i586
perl-Unicode-Map8-0.12-5mdk.i586
perl-Unicode-MapUTF8-1.09-4mdk.noarch
perl-Unicode-String-2.07-4mdk.i586
Is this OK? (Y/n)

ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/main/perl-Unicode-String-2.07-4mdk.i586.rpm
ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/main/MHonArc-2.6.10-1mdk.noarch.rpm
ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/contrib/perl-Unicode-Map-0.112-4mdk.i586.rpm
ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/contrib/perl-Unicode-MapUTF8-1.09-4mdk.noarch.rpm
ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/contrib/perl-Jcode-0.86-2mdk.i586.rpm
ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/contrib/perl-Unicode-Map8-0.12-5mdk.i586.rpm
installing perl-Unicode-String-2.07-4mdk.i586.rpm perl-Unicode-MapUTF8-1.09-4mdk.noarch.rpm perl-Unicode-Map-0.112-4mdk.i586.rpm perl-Jcode-0.86-2mdk.i586.rpm perl-Unicode-Map8-0.12-5mdk.i586.rpm MHonArc-2.6.10-1mdk.noarch.rpm from /var/cache/urpmi/rpms
Preparing... #############################################
1/6: perl-Unicode-String #############################################
2/6: perl-Unicode-Map8 #############################################
3/6: perl-Jcode #############################################
4/6: perl-Unicode-Map #############################################
5/6: perl-Unicode-MapUTF8 #############################################
6/6: MHonArc #############################################


Then look for documentation ... google it, and here we go...
The big one:
http://www.mhonarc.org/MHonArc/doc/index.html

The quickstart:
http://www.mhonarc.org/MHonArc/doc/quickstart.html#folders

Ok, we have some infos...

[bsergean@flanders ~]$ cd public_html/
[bsergean@flanders public_html]$ mkdir mailarchives
[bsergean@flanders public_html]$ cd mailarchives
[bsergean@flanders mailarchives]$ mhonarc -outdir . ~bsergean/mail/admin
This is MHonArc v2.6.10, Perl 5.008006 linux
Converting messages to .
Reading /home/bsergean/mail/admin ................................................................................

Writing mail ...............................................................................
Writing ./maillist.html ...
Writing ./threads.html ...
Writing database ...
79 new messages
79 total messages

And from the doc, we can guess which url we will give to firefox:

MHonArc creates the following files after processing the mail folders:

* maillist.html: The main index file containing links to all mail messages converted. Messages are listed with subjects and who the messages are from. All messages are listed by the date.
* threads.html: The file listing messages by threads.
* msg*.html: HTML versions of the mail messages, where * represents a message number from 0 to the number of message processed minus 1.
* .mhonarc.db (or mhonarc.db under Windows): This database file contains archive information and resource settings for MHonArc to perform further updates.

Other: If messages contain attachments, other files may be created for images, videos, binaries, etc.

Here we are... the url for me will be
http://myhostname/~bsergean/mailarchives/threads.html

Now the fun thing is to subscribe to a big bandwidth mailing list, and then update this archive nightly for example.

First, I create a procmail filter:
# automatic build mails
:0:
* ^Subject:.*Unix nightly builds
uxbuilds

I create this uxbuilds folder with my emailer (pine).

Then, a crontab:
Edit it with crontab -e, and add this line:
0 7 * * 1-5 /share/common/bin/mypipermail.sh

And here is a dummy script which do the job.

#!/bin/sh

# html output prefix
hprefix=~/public_html/mailarchives
# mail prefix
mprefix=~/mail

# maildirs to archives
mdirs="
uxbuilds
"

for md in $mdirs
do
hdir=$hprefix/$md
test -d $hdir || mkdir -p $hdir

mdir=$mprefix/$md
if test ! -f $mdir ; then
echo "No such maildir: $mdir"
continue
fi

mhonarc -add -outdir $hdir $mdir
done


Enjoy !!

Sunday, June 11, 2006

Host your own wikipedia

A quick newbies wikimedia (the wiki engine behing wikipedia) setup for Mandrakelinux release 10.2 (Limited Edition 2005)
(should work on newer release thought).

I suppose apache has userdir enabled. Just download the tarball from the mediawiki sourceforge page, and decompress it into your ~/public_html/
cd ~/public_html
gunzip < media-version.tgz | tar xf -
mv big-wiki-name wiki
chmod a+w config

Then, point your browser to the install url (classical php install).
http://yourhostname/~bsergean/wiki/config/index.php

Then, we have to install some packages ... thanks to the error message that are shown (look how to use urpmf to get package name depending on some file path).

[bsergean@flanders wiki]$ urpmf mysql.so | grep php
php-mysql:/usr/lib/php/extensions/mysql.so
php5-mysql:/usr/lib/php5/extensions/mysql.so
[bsergean@flanders wiki]$ su
[root@flanders wiki]# urpmi php-mysql

ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/main/php-mysql-4.3.10-7mdk.i586.rpm
installing php-mysql-4.3.10-7mdk.i586.rpm from /var/cache/urpmi/rpms
Preparing... #############################################
1/1: php-mysql #############################################
[root@flanders wiki]# exit
[bsergean@flanders wiki]$ su
[root@flanders wiki]# urpmi php-xml

ftp://mirrors.usc.edu/pub/linux/distributions/mandrakelinux/official/2005/i586/media/main/php-xml-4.3.10-5mdk.i586.rpm
installing php-xml-4.3.10-5mdk.i586.rpm from /var/cache/urpmi/rpms
Preparing... #############################################
1/1: php-xml #############################################

Now you have to restart the web server, so that the updated php actually is loaded.

[root@flanders wiki]# service -f httpd
Shutting down httpd2: [ OK ]
Starting httpd2: [ OK ]
[root@flanders wiki]#

OK, now we are ready to configure mediawiki. The next big thing is to configure the database (mysql) actually: This is the official page for version 5.
http://dev.mysql.com/doc/refman/5.0/en/index.html

On our config, the database is locally hosted.

Adding user is documented here:
http://dev.mysql.com/doc/refman/5.0/en/adding-users.html

[bsergean@flanders wiki]$ mysql --user=root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.11

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'wikiuser'@'localhost'
-> IDENTIFIED BY 'replace_here_with_your_password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.02 sec)

Then, create the db:

So the basic Mandrake install doesn't set the default root password.

[bsergean@flanders wiki]$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16 to server version: 4.1.11

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('replace_by_new_root_password');
Query OK, 0 rows affected (0.02 sec)

mysql> Bye

[bsergean@flanders wiki]$ mysqladmin -u root -p shutdown
Enter password:
[bsergean@flanders wiki]$
[bsergean@flanders wiki]$
[bsergean@flanders wiki]$
[bsergean@flanders wiki]$ ps -ef | grep mysq
bsergean 28191 17261 0 20:11 pts/2 00:00:00 grep mysq

We restart the server as root:

[bsergean@flanders wiki]$ su
[root@flanders wiki]# service mysqld start
Starting MySQL: [ OK ]

Now we login as wikiuser :

[bsergean@flanders wiki]$ mysql -u wikiuser -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.1.11

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE wikidb;
Query OK, 1 row affected (0.01 sec)

mysql> Bye

Looks like it's done now !!

I have left all the other param to the default value but those ones:

wiki name, admin email ... the easy ones :)
Wiki admin: replaced by root (the regular admin name, no ?)

Then, to speed up thing (if you expect lots of users), we'll urpmi memcached ... whose default port from the man page is 11211
So in the associated box, we'll enter : localhost:11211

We have to start the service, and edit /etc/init.d/memcached, to add the -u mysql to the daemon line. Otherwise you'll get this message :

Starting memcached: can't run as root without the -u switch
[FAILED]
But after the modif ... ->
[root@flanders init.d]# service memcached start
Starting memcached: [ OK ]

Now we click on the Install button ...
And looks like it worked !!

To finish, we just have to move the config/LocalSettings.php file into the parent director

[bsergean@flanders wiki]$ mv config/LocalSettings.php .
# This one just to be sure ...
[bsergean@flanders wiki]$ chmod 755 config

Then, go to http://yourhostname/~bsergean/wiki ...
You're done !!
Now another story begins ;)

Monday, June 05, 2006

Villipandé par l'arbitre

Je sais pas si tu vous vous rappelez, mais on avait identifié cette technique d'utilisation de mots compliqués par les journalistes sportifs pour avoir l'air moins bête. Aujourd'hui j'entends à la radio un dresseur de chiens au sujet des pitbulls, et des gens qui achètent des petits nounours de deux mois, et qui pensent qu'il ne vont pas changer et se transformer en monstre :
(au journaliste)
"Ecoutez, je crois qu'il faut arrêter de faire de l'anthropomormisphe"

La boucle est bouclée.