Place Ghantoos

My memo -cheatsheet- page

I have added a new page to my blog today. It lists commands/tips I collected over the past couple of month. I will be updating it every once in while.

Please don’t hesitate to comment suggesting/correcting commands :)

I hope this can be useful!

Cheers,
Ignace M -ghantoos-

Mounting UFS in read/write under Linux (debian)

A week ago, I encountered some space problems on my FreeBSD system during a system wide portupgrade. Fortunately, I had backed up my system just before the adventure, so my system was saved.

The procedure I followed to restore my data, was:
1- recreate my partitioning, giving 10 more Gigs to the system, using the FreeBSD installation CD
2- copy all the data on it

Since I backed up my FreeBSD system on an external ext3 hard drive, I needed to copy it back from “outside” my freebsd system. My first option was to use Fixit from the FreeBSD installation CD set, but I had problems mounting my partition because of the inode block size of my ext3 partition. Bref. I decided to mount everything from my Linux (ubuntu) system, and copy everything back from there!

I only way to do this was to recompile my kernel with the right “UFS write” flag. And it JUST WORKED!! I copied back __ALL__ my FreeBSD system on the new slices, rebooted my machine, and here I am writing this post from my old-new FreeBSD system! :)

Read the rest of this entry »

Creating a .deb package from a python setup.py

This article has been updated on July 2nd 2009.

As I worked on packaging a project I am working on (Limited Shell) I found my self reading many tutorials on how to build debian packages. But none where related to distutils setup.py. As a nice setup.py natively knows how to package RPM, I thought about a way to include setup.py in a .deb generation.

Here is a small guide to help generate a debian package from a distutils/setuptools setup.py.

The main steps of this procedure are:
1- make sure that your setup.py is functional
2- generate a GPG key to sign your package and a public key to put on your server or wherever
3- create the files that are useful for the debian packaging:
* debian/changelog
* debian/compat
* debian/control
* debian/copyright
* debian/rules
* debian/watch
4- write the Makefile
5- generate your debian package
6- check your files’ licensing
7- check your new package using lintian
8- Conclusion
9- Links

Read the rest of this entry »

YUM output parser (yum-parser.py)

As I needed to minimize yum’s output for a project I was working on, I thought it was just about changing the debugging level. But I found out yum’s debugging level could add information, but not minimize it. So wrote a small python script that does the job.

What I wanted to do, is replace yum’s output with a very simple progress bar showing only the different stages of a yum procedure (dependencies/download/install/remove/update).

The script is quite easy to use:

Usage:
	$ yum-parser.py (-u | --update)
	$ yum-parser.py (-i | --install) package_list
	$ yum-parser.py (-r | --remove) package_list
	$ yum-parser.py (-s | --search) 'regexp'
	$ yum-parser.py (-h | --help) package_list

For a reason I still ignore, when redirecting yum’s generic output to a file (e.g. yum -y install irssi 2>&1 > yumoutput), the “Downloading Packages” part doesn’t appear. To remedy this problem, I had to insert some threading to have a “patience bar” (i.e. back and forth [ = ]) while the downloads are processed.

You can find the source code here.

Read the rest of this entry »

Limited Shell (lshell)

As I was wondering how I could do to relieve my wrt54gl from the huge weight of libopenssl and nsupdate, I thought.. Wouldn’t it be cool if I could set a very restricted account on my server, and just ask my wrt54gl to ssh to it and execute locally nsupdate. So I started searching for a way to restrict user ssh accounts by listing a set a allowed commands. No luck there.

So.. python came to the rescue.

Limited Shell (lshell) is an application that lets you restrict the environment of any SSH user. It provides an easily configurable shell: just choose a list of allowed commands for every limited account. No installation is required.

You can download the current version of lshell from the following link: http://sourceforge.net/project/showfiles.php?group_id=215792

If you want to contribute to this project, please do not hesitate.
Send me a patch, or just your new lshell.py so I can check it out.
You can use the interface on sourceforge.net:
http://sourceforge.net/projects/lshell/

Cheers,
Ignace M -ghantoos-

WRT54GL: OpenWRT Kamikaze 0.9 and dynamic DNS (nsupdate/bind)

Hello again,

My first objective was to update my DNS from my home. The problem was:
1- I wanted it to be secure (at least the most secure possible)
2- my PC is behind a beautiful WRT54GL which leaves me with nothing but my LAN IP.
I had to install the stuff on my linksys running Kamikaze0.9 of OpenWRT.
After some research and some small space headaches (WRT54GL), here is what I did:
Read the rest of this entry »

Nokia N70 (S60 series), python and your PC

Here is a small briefing of how to connect your Nokia S60 series and your PC through bluetooth:
1- to send a file to your mobile
2- to get your mobile python console on your box!

Read the rest of this entry »

python: pyExcelerator module very little howto

As a small reminder for myself, I post the thread about pyExcelerator.

pyExcelerator is a nice little python module that let’s you write Excel files (not openOffice spreadsheet, the other kind..).

For Ubuntu users, it is very easy to install: sudo apt-get install python-excelerator

Here basic script to write in ‘Hello World!’ excel file:

#!/usr/bin/env python    

import os
from pyExcelerator import *    

curpath = os.path.dirname(__file__)   

workbook = Workbook()
worksheet = workbook.add_sheet('My colour Sheet')
worksheet.write(0,0, 'Hello World!')
workbook.save(os.path.join(curpath, 'test.xls'))

Read the rest of this entry »

L’open-source, rempart aux effets néfastes de l’orgueil du développeur… By Stephbul

Voici un article clairvoyant notant la différence entre la fierté et l’orgueil d’un développeur qui publie son travail en opensource.. ou pas.

http://www.bulot.org/2007/10/25/lopen-source-rempart-aux-effets-nefastes-de-lorgueil-du-developpeur/

cheers Stephbul!

Ghantoos

kvm/qemu bridging with dummy network card

I wanted to setup some VMs using kvm (i had the same problem using xen). The solution a chose to connect my VMs to the internet was to do it through bridging.
My only problem is that my eth0 (main and only ethernet card is connected straight to the Internet. So bridging loses its meaning because I could not choose new IP addresses for my virtual boxes.

The solution: creating a dummy network interface!

With this scenario, i’ll have all my dumUs bridged to the dummy interface (dummy0) and the bridge (br0) NATed through eth0. I hope I’m clear enough. : )

Here is how my /etc/network/interfaces file looks like:
Read the rest of this entry »