giovedì 27 dicembre 2012

Canon MF4350D and Ubuntu

Now there is a PPA for 64-bit drivers! https://launchpad.net/~auanswers/+archive/canon64/

mercoledì 25 luglio 2012

Ubuntu USB Boot with Grub2

grub-install --no-floppy --root-directory=/media/E7E0-092F/ /dev/sdb cp ubuntu-12.04-desktop-i386.iso /media/E7E0-092F

Edit /media/E7E0-092F/boot/grub/grub.cfg

menuentry "Ubuntu 12.04 ISO" { set isofile="/ubuntu-12.04-desktop-i386.iso" loopback loop (hd0,msdos1)$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject initrd (loop)/casper/initrd.lz }

martedì 29 dicembre 2009

Crosscompilation for armel with emdebian

First of all create a chroot with debootstrap:

debootstrap lenny armchroot

Then let's go to fix locales:

mount none -t proc armchroot/proc
chroot armchroot
@armchroot: apt-get update && apt-get install locales&& dpkg-reconfigure locales && apt-get install localepurge

The last important part is to install emdebian-tools

@armchroot: apt-get install emdebian-tools


@armchroot: apt-get update && apt-get upgrade

Now we have to edit /etc/emsource.conf to use stable

targetsuite: lenny

Now it's time to setup emdebian. We want to crosscompile to armel so:

@armchroot: emsetup -a armel

This last command will install and configure the toolchain.

Gitweb with Lighttpd on a debianized NSLU2

First of all install Lighttpd gitweb and git

apt-get install lighttpd gitweb git-core

Then add a lighttpd configuration file.

server.modules += ( "mod_cgi" )
url.redirect = ( "^/git$" => "/git/" )
alias.url += ( "/git/" => "/usr/lib/cgi-bin/" )
$HTTP["url"] =~ "^/git/" {
cgi.assign = ( ".cgi" => "" )
index-file.names = ( "gitweb.cgi" )
}

Wrote this in /etc/lighttpd/conf-available/10-gitweb.conf.
The copy the three files in /usr/share/gitweb in /var/www.
Now edit projectroot field in your gitweb configuration file in /etc/gitweb.conf:

$projectroot = "/your/directory/git";

Save /etc/gitweb.conf and enable gitweb configuration for lighttpd:

lighttpd-enable-mod gitweb
invoke-rc.d lighttpd force-reload

An UML2 Diagram editor for Linux

Googling I found Gaphor. Iwas bored of Dia. Gaphor uses dia canvas but it's more UML2 oriented ant it's write in python!
Unfortunally debian package of gaphor depends on python-zope.interface that is broken.
So I decided to use python-virtualenv to install gaphor.

As root:

root@thelemasys:~# aptitude install python-virtualenv


And then as user:

denever@thelemasys:~$ virtualenv gaphor
denever@thelemasys:~$ cd gaphor
denever@thelemasys:~/gaphor$ source bin/activate
(gaphor)denever@thelemasys:~/gaphor$ easy_install gaphor
(gaphor)denever@thelemasys:~/gaphor$ gaphor

giovedì 5 novembre 2009

Configuring a Canon MF4350D on Ubuntu Karmic Koala 64bit

First of all you have to download Canon propetary drivers from here.

After you download Canon_UFRII_Linux_V1.90_[your country code here].tar.gz, untar it.

That will create a directory: Canon_UFRII_Linux_V1.90_IT/


denever@tuscio:~/tmp/src$ cd Canon_UFRII_Linux_V1.90_IT/
denever@tuscio:~/tmp/src/Canon_UFRII_Linux_V1.90_IT$ cd 64-bit_Driver/
denever@tuscio:~/tmp/src/Canon_UFRII_Linux_V1.90_IT/64-bit_Driver$ cd RPM/
denever@tuscio:~/tmp/src/Canon_UFRII_Linux_V1.90_IT/64-bit_Driver/RPM$


In this directory you will have two rpm:

denever@tuscio:~/tmp/src/Canon_UFRII_Linux_V1.90_IT/64-bit_Driver/RPM$ ls
cndrvcups-common-1.90-1.x86_64.rpm cndrvcups-ufr2-uk-1.90-1.x86_64.rpm


Now you have to convert these two rpm in two debian package (.deb).
To do this you will need alien program installed.

sudo apt-get install alien


After you installed alien you can convert the two rpm:

alien cndrvcups-common-1.90-1.x86_64.rpm
alien cndrvcups-ufr2-uk-1.90-1.x86_64.rpm


After that you have to install ia32-libs.
This package is really important for the right use of the driver:

sudo apt-get install ia32-libs


And now you can install the two debs:

sudo dpkg -i cndrvcups-common_1.90-1_amd64.deb
sudo dpkg -i cndrvcups-ufr2-uk_1.90-1_amd64.deb

giovedì 30 luglio 2009

How to extract an image from a swf?


root@evans:~# apt-get install swftools
denever@evans:~$ swfextract file.swf
Objects in file file.swf:
[-i] 3 Shapes: ID(s) 2, 4, 6
[-j] 3 JPEGs: ID(s) 1, 3, 5
[-f] 1 Frame: ID(s) 0
denever@evans:~$ swfextract -j 1 -o image1.jpg
denever@evans:~$ swfextract -j 3 -o image3.jpg
denever@evans:~$ swfextract -j 5 -o image5.jpg

giovedì 11 giugno 2009

turbogears 1.0 in debian is broken

turbogears 1.0 in debian is broken.
So how to fix it?

easy_install "turbojson=1.1.4"
easy_install "turbojson<1.2"
easy_install "TurboCheetah>=1.0"
easy_install "TurboGears>=1.0.8"

mercoledì 10 giugno 2009

How to retrieve a .dsc file giving only the pkg name

pkgurl=$(dcontrol $1 | grep ^Filename | head -1 | cut -d' ' -f 2 | sed s/_[a-zA-Z0-9]*.deb/.dsc/) dget -q http://ftp.uk.debian.org/debian/$pkgurl
dpkg-source -x $(basename $pkgurl)

domenica 12 aprile 2009

Italian Keyboard Layout Coder Friendly

This post is about Italian Keyboard and concern to italian speaking people, so I'm writing in italian.

Bene questo è il mio primo post in italiano, spero di non commettere strafalcioni come in inglese.
Dunque oramai da almeno due anni utilizzo un mio personale layout di tastiera.
Questo perché ero stanco di fare acrobazie con la tastiera quando scrivevo codice.

Chi di scrivendo codice in C o in PHP ad esempio non vorrebbe avere a portata di mano le parentesi graffe?

Chi di voi usando la bash non vorrebbe avere la tilde o la slash a portata di mano e non nascosta dietro AltGr o Shift?

Ora la tastiera italiana si caratterizza per avere le accentate ùèòàìé e tanti altri caratteri strani di cui ignoro, ad esempio la c con cediglia.
Qualcuno di voi l'ha mai usata?
Io no.
Eppure sta li in mezzo ai cabbasisi come direbbe Montalbano.
Non sarebbe più comodo avere la pipe li, quando si sta usando la bash?

Ecco a queste mie noie ho cercato di dare risposta creando un mio layout di tastiera.
Che vi mostro graficamente:


Come vedete ho messo la slash e la tilde (accessibile con un semplice shift) a fianco della L.
La pipe e la "chiocciola" sono a seguire facilmente accessibili (con il mignolo :) ).
Ancora a seguire il cancelletto e l'apice inverso (utilissimo, ad esempio, in bash e in latex)
Come vedete le graffe e le quadre sono li dove si trovano sulla tastiera UK, US.
Come tutti però oltre a scrivere codice scrivo anche testo in italiano :)
Quindi non ho fatto fuori le accentate. Semplicemente le ho piazzate sopra i numeri come potete vedere in figura.
Posso accedervi con AltGr + il numero corrispondente. Si, adesso sono le accentate a non essere a portata di mano, ma visto il ridotto utilizzo che ne faccio non è un problema per me.
Ho fatto fuori il simbolo della sterlina che si trovava sul numero 3 ed al suo posto ho messo il simbolo dell'euro € :)

Cosa ne pensate? :)

domenica 5 aprile 2009

p54usb and the wrong regulatory domain

In these days I used often my flybook. It is equipped with a WiFi Usb integrated dongle.
It came out that it's a prism54 chipset. So I could use p54usb module from the kernel.
But I discovered a problem. My netbook doesn't associate in any way to my Access Point.
At first I couldn't figure out why. So I gave up. I thought that was a problem in my hardware.
Yesterday, I noticed an error message from the kernel:


[ 193.290086] phy0: frequency change failed
[ 193.290155] phy0: failed to set freq to 2467 MHz for scan


This arouses my suspicion.
I decided to figure out more about this error.
So I looked for this string in drivers/net/wireless/p54/*.{c,h}.

denever@v33i:~$ grep -l "frequency change failed" driver/net/wireless/p54/*.{c,h}
p54common.c

I took a look to the code. And I decided to add some printf line to figure out where the problem is.
Then I discovered that p54common tries more frequencies to find the right one.
But if none of the set available matches then print out that error message.
So how is choosed the frequencies set?
Looking more carefully to the dmesg I found this line:

[ 131.901612] cfg80211: Using static regulatory domain info
[ 131.901621] cfg80211: Regulatory domain: US

So here we are!!!
My usb dongle uses the wrong frequency set.
But how can I change this frequency set?
I googled around discovering some interesting things.
First of all, I discovered that cfg80211 implements a regulatory compliance.
And actually since cfg80211 came in to the kernel I experimented problems with my wifi dongle.
Reading here, I discovere that is possible to choose the regulatory domain setting a parameter of the cfg80211 module.
So I wrote a config file for modprobe and I placed it in my /etc/modprobe.d/.
Here follows my cfg80211.conf:

denever@v33i:~$ cat /etc/modprobe.d/cfg80211.conf
options cfg80211 ieee80211_regdom=EU

And now my dongle connect really fine :)
My dmesg:

denever@v33i:~$ dmesg | grep cfg80211
[ 131.901612] cfg80211: Using static regulatory domain info
[ 131.901621] cfg80211: Regulatory domain: EU

mercoledì 11 febbraio 2009

Kernel needs initramfs

When you recompile your kernel and you want to use initramfs remember to select this option:


General Setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support


And if you want to generate your initramfs with kernel-package in debian remember the option --initrd.

martedì 20 gennaio 2009

Rembember remember remember


for I in *.txt;do grep -H $(basename $I .txt) $I; done


You don't know why. But I assure you it's useful for me...

lunedì 19 gennaio 2009

Imagemagick cropping 18Mb of png files

In these days I need to crop a lot of png file. They are screenshots of a desktop 1024x768 and I need to remove a frame around the main window. So I didn't want to use a program like gimp opening each file and crop it. So I thought to use a shell script with convert an utility from Imagemagick suite.
This is the code of the shell script:


for I in $(find -name *.png);do
convert -shave 0x46 -crop 1024x768+0+28 $I $I.crop
mv $I $I.old
mv $I.crop $I
done

giovedì 18 dicembre 2008

Giving a GTK+ Interface to OCrypt.py using Glade

RCLUG invited Gianni Amato to LinuxDay2008 as speaker on Forensic Analysis with Linux. It is really nice to make Gianni’s acquaintance. He is really competent! Speaking with Gianni I discover that he wrote a nice python script to crypt/decrypt files called OCrypt.py. OCrypt.py has a GUI interface written in Tkinter. Gianni would like to write a GTK+ interface, but he hadn't much free time. So I offered to write a GTK+ interface for OCrypt.py using PyGtk and Python. Now, I recorded the creation of the interface with Glade using recordmydesktop.
There isn't my voice in these days I have a sore throat...



You can find updated glade file and the python script of OCrypt-gtk.py on my github.com repository.

lunedì 15 dicembre 2008

DNS queries logging on WRT54GL

This morning I came up with another idea.
The last year I would try datamining on DNS data from my local dnsmasq.
But how could I collect all the queries of dnsmasq if it is installed on a WRT54GL without writing on the flash?
This morning I think, easy denever you could email the logs of dnsmasq on a dedicated gmail account.
So I looked for an smtp client on Kamikaze 7.09 which is installed on my WRT54GL:


root@openwrt:~# ipkg info *smtp*
Package: ssmtp
root@openwrt:~# ipkg install ssmtp


Taking a look there I could configure /etc/ssmtp.conf as follows:

root={your email acc name}@gmail.com
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
hostname=gmail.com
FromLineOverride=YES
UseTLS=YES
AuthUser=your username
AuthPass=your password


And then how to log queries with dnsmasq?
Reading the documentation of dnsmasq I find:

The log-queries option tells dnsmasq to verbosely log the queries it is handling and causes SIGUSR1 to trigger a complete dump of the contents of the cache to the syslog.

So in /etc/dnsmasq.conf I added the following line

log-queries

But on Kamikaze 7.09 where dnsmasq writes the logs?
Dnsmasq uses syslogd for the logging.
Taking a look to /etc/init.d/boot you can find this:

syslogd -C16 ${log_ip:+-L -R $log_ip}

So how to read the logs? Easy we use the logread.
How could we email this logs? For this purpouse I wrote a script:

root@openwrt:~# cat /bin/print_dnslog.sh
echo -e "Subject: DNS Log\n"
logread | grep query


And then we could email everything, using another script:

root@openwrt:~# cat /bin/mail_dnslog.sh
/bin/print_dnslog.sh | ssmtp mybackup_mail@gmail.com

And then I want that mail_dnslog.sh running periodically so reading here and here I wrote a simple crontab.

root@openwrt:~# crontab -e
* * * * * /bin/mail_dnslog.sh

domenica 14 dicembre 2008

NSLU2 && lighttpd && esmtp

This morning I came up with an idea. How could I know when someone access to my lighttpd webserver installed on my NSLU2?

The answer is easy, denever, active mod_accesslog and then take a look to the access.log!

Ok, but if I want to reaceive a mail for each access? :)

Reading there, I discovered that it is possible to redirect the access.log to a process.

So I wrote this line in the /etc/lighttpd/lighttpd.conf on my NSLU2:

accesslog.filename = "| mail -i -s Webaccess my_email@anywhere.com"


The I installed and configured esmtp on my NSLU2:

apt-get install esmtp

Editing /etc/esmtprc:

hostname=smtp.googlemail.com
username=yourname@gmail.com
password=yourpass
starttls=enabled

But there is a problem: lighttpd write access.log only when is stopped...
So I shall not receive an email on each access on my webserver.
I will receive an email on each restart of lighttpd.

venerdì 12 dicembre 2008

GMAIL + IMAP + MUTT

How to use our gmail account from console with mutt?

So this is how I configured mutt to access my gmail account via IMAP.

Open your ~/.muttrc and set the following options

If your user account on gmail is yourname@googlemail.com then set your folder as follow:


set folder = imaps://yourname@imap.googlemail.com
set imap_pass = yourpass

Notice...yourpass will be saved in clear text on ~/.muttrc.

Do you want to save your postponed mail (written with mutt) on gmail drafts? :)

Add in your ~/.muttrc the following row:


set postponed = "=[Google Mail]/Drafts"


And now, how to send email from mutt via smtp.googlemail.com?

As MTA I installed esmtp:

apt-get install esmtp


Then I configured mutt to use esmtp as MTA, adding in ~/.muttrc:

set sendmail = "esmtp -v -X ~/tmp/esmtp.log"


Then I configured esmpt editing /etc/esmtprc:

hostname=smtp.googlemail.com
username=yourname@gmail.com
password=yourpass
starttls=enabled

Notice that also /etc/esmtprc is a clear text, so yourpass would be read from root