Matteo Mattei

Hello, my name is Matteo Mattei and this is my personal website. I am computer engineer with a long experience in Linux system administration and web software development.

linkedin rss twitter google+ github facebook

Script to remove .svn directories from a project

When you want to distribute your own sources without any .svn directories is sufficient to create an export of the project with this command:

svn export svn://path_to_repository projectname

But often I have not access to the repository, so I remove any .svn directory by hand.

For a couple of directories is not a problem but today I have a big project with hundreds of directories, so I created a little script to help me:

find . -type d -name .svn -exec rm -r '{}' \;

Replace “.” with your root folder.


Codesourcery G++ for ColdFire on OpenSuse 10.3 and some problems during IDE installation

In these days at work we are evaluating to buy a cross-compiler IDE of ColdFire developed by CodeSourcery G++. The development environment is substantially Eclipse optimized for that cross-compiler. During installation of the package we have discovered a lot of problems running the IDE installation and the next license installation.

From the official site must download the *.bin package that contains all the necessary, but after run, we have always obtained this error:

eclipse.bin: xcb_xlib.c:52: xcb_xlib_unlock: Assertion `c->xlib.lock’ failed

To solve this issue is sufficient to insert this line into ~/.bashrc:

export LIBXCB_ALLOW_SLOPPY_LOCK=1

and reload the file:

source ~/.bashrc

Well, proceed with installation and complete it. At the end a wizard license will be prompt but it was never appear to us, may be because of some problem about the MAC address of our virtual machine (we work under vmware). So, we have prepared a new computer with native Linux, put it out of the net (probably the license evaluation file it will be downloaded directly from Internet during installation), waiting the wizard appear, download the license from CodeSourcery site by hand and import it to the wizard itself.

Only after all these fix and tries we were finally able to work with the new development environment. Unfortunately, using it we have discovered that sometimes Eclipse crashes with no sense and we have not yet understand why.


OpenSuse 10.3 CD and DVD with fault installer? Reinstalling the bootloader!

Today I tested the new OpenSuse 10.3 with KDE both in CD and DVD version on an old Packard Bell Desk Pro. After a long wait during installation, at automatic reboot it will be prompt a classic black screen with the message “Operative System not present”. After a vanished search on the net looking for some informations, I thought that the installer was failed to install the bootloader and so I have just tried to do it manually. Here there are all the steps I follow:

  • Boot OpenSuse installation CD/DVD and enter in Recovery mode
  • Run grub ed enter in its own shell
  • From here run these commands:
grub> root (hd0,1)
grub> setup (hd0)
grub> quit

Where:

  • hd0,1 => sda2
  • hd0 => sda </li>

Restart the system and magically the installation will go on.


Install yum and php-pear on Centos 5

Virtual server like Aruba virtual servers are configured with Centos without yum and without php-pear. Today I have done an assistance to a server of my customer that needed pear installation. It is quite simple to make all work but I don’t understand why Aruba’s staff have not decided to include yum in their own default configuration server…

Shall we start installing yum:

mkdir /root/matteo && cd /root/matteo
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/gmp-4.1.4-10.el5.i386.rpm
rpm -Uvh gmp-4.1.4-10.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/readline-5.1-3.el5.i386.rpm
rpm rpm -Uvh readline-5.1-3.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-2.4.3-27.el5.i386.rpm
rpm -Uvh python-2.4.3-27.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-2.6.26-2.1.2.8.i386.rpm
rpm -Uvh libxml2-2.6.26-2.1.2.8.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-python-2.6.26-2.1.2.8.i386.rpm
rpm -Uvh libxml2-python-2.6.26-2.1.2.8.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/expat-1.95.8-8.3.el5_4.2.i386.rpm
rpm -Uvh expat-1.95.8-8.3.el5_4.2.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
rpm -Uvh python-elementtree-1.2.6-5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/sqlite-3.3.6-5.i386.rpm
rpm -Uvh sqlite-3.3.6-5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
rpm -Uvh python-sqlite-1.1.7-1.2.1.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/elfutils-0.137-3.el5.i386.rpm
rpm -Uvh elfutils-0.137-3.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/rpm-python-4.4.2.3-18.el5.i386.rpm
rpm -Uvh rpm-python-4.4.2.3-18.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/m2crypto-0.16-6.el5.6.i386.rpm
rpm -Uvh m2crypto-0.16-6.el5.6.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm
rpm -Uvh python-urlgrabber-3.1.0-5.el5.noarch.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
rpm -Uvh yum-3.2.22-26.el5.centos.noarch.rpm
yum -y update

Now it’s time to install php-pear:

yum install php-pear*

Ok, in every virtual-host of Plesk (/var/www/vhosts/example.com/conf/httpd.include), there is the directive open_basedir that must be configured in the right way adding the pear path:

php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs:/tmp:/usr/share/pear:/local/PEAR"

We must also configure pear in /etc/php.ini

include_path=".:/usr/share/pear:/local/PEAR/"

At the end you shall restart Apache:

/etc/init.d/httpd restart

Hide file and directory in Apache disabling browsing

If you want to disable file and directory browsing on your Apache web server in order to prohibit that every users can view the content of a directory (if noindex.php/index.html is present) you need to modify the Apache configuration a little or add a new statement in .htaccess file.

I will show you how to do in both cases:

  1. Apache configuration: httpd.conf/virtual-hosts
    Edit your virtualhost adding these rows:
<Directory "/home/httpd/html/mydomain/files">
    Options -Indexes
</Directory>
  1. .htaccess
    Add in the .htaccess file this row:
Options -Indexes

In the first case you need to restart apache server.


Script to remove trailing tilde (~) from temporary files

Using kate as similar text editors, temporary files that have been saved present an annoying trailing tilde that I personally consider useless. I am used to be careful when I edit a file, so I don’t need the backups. For this reason I developed this mini script in bash to remove temporary files from a folder.

#!/bin/bash
rm `find $1 | grep "~$"`

I called the above file rmm and I put it in /usr/bin/ folder. To use it, just place in the folder you have files with trailing slashes and execute it:

$ rmm .

Or directly passing the folder as the first argument:

$ rmm /home/matteo/src

This script is trivial and can be obviously improved. If you want to contribute I will be happy to add your improvements.