My own flavour of network config automatic choosing

Until a couple of days ago, I used to use Gnome network-admin’s ability of having multiple network profiles to configure my wifi card at work and at home. But yesterday, the program went crazy and started to crash without any logical reason and I decided to shift to another solution: logical network interface mapping.

Interface mapping is a feature of ifupdown (/etc/network/interfaces). You can define some logical interfaces and call a script in order to choose which one will be mapped to a physical interface. The /etc/network/interfaces could be like this one (being HomeNET and WorkNET two existing ESSID network identifiers):

auto eth1
mapping eth1
script /root/WIFI/wldetect.sh
map HomeNET HomeNET
map WorkNET WorkNET

iface HomeNET inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
wireless-essid HomeNET
wireless-key s:mysecretpass1 open
dns-nameservers 127.0.0.1 192.168.1.1

iface WorkNET inet dhcp
wireless-essid WorkNET
wireless-key s:mysecretpass2 open
dns-nameservers 127.0.0.1 192.168.100.1

I’m using resolvconf to activate the dns-nameservers directive in the interfaces file, and dnsmasq to take care of some dns issues with a couple of VPNs I use. That explains the first 127.0.0.1 entry.

The script /root/WIFI/wldetect.sh lists the available networks and chooses one of them being in a whitelist (HomeNET|WorkNET):

#!/bin/sh

# Config
WL_IFACE=`iwconfig 2>/dev/null | { read A _; echo $A; };`

# Reset the interface
ifconfig $WL_IFACE down
ifconfig $WL_IFACE 0.0.0.0
ifconfig $WL_IFACE up

# Search networks
NETWORKS=`iwlist $WL_IFACE scanning | grep ESSID | sed -e ‘s/.*”(.*)”/1/’`

# Bring down the interface
ifconfig $WL_IFACE down

# Select preferred networks
for NET in $NETWORKS
do
case $NET in
HomeNEt|WorkNET)
echo $NET;
exit 0;
;;
esac
done
exit 1;

And that’s all! I hope that this configuration could be helpful for someone.

Logitech QuickCam Express (USB ID 046d:092f) on Ubuntu Edgy

I’ve just bought the webcam in the title of this post at Alcampo and had a hard time trying to set it working.

In the pkg-spca5xx-devel Debian mailing list, Dmitry Semyonov says that this camera model is supported by the spca5xx driver, but its ID isn’t added to the driver source code yet. He’s published a patch, and I tried to apply it, but the patch utility complained. That was because the tabs would have been replaced with spaces or something. Then I discovered the “-l” option, which solved my problem and I could finally apply the patch.

At help.ubuntu.com I found detailed instructions about how to build the spca5xx source code, so, finally I had the work done.

I’ve written a recipe to perform all the steps. At first, copy the patch into the file /tmp/qcexpress.patch. Next, execute these instructions:

apt-get install spca5xx-source
cd /usr/src
tar jxvf spca5xx-source.tar.bz2
cd modules
patch -lp1 < /tmp/qcexpress.patch
cd spca5xx
make
make install

That’s all!
And, at the end, a living proof: MSN video chat using Kopete 🙂
MSN video chat with Kopete