Archive for the ‘Projects’ Category

* cmake error at … library not found

Posted on December 30th, 2011 by Alex. Filed under Linux.


If you use cmake and have a library whose header files cannot be found, since you compiled your own library and put it somewhere where you can find it again, cmake will most likely abort with an error message like:

– Current HG revision is cf9be9344356
– Assuming this is a tarball (release) build for 2011.4.0
– Found wxWidgets: TRUE
– Found TIFF: /usr/include
– Found JPEG: /usr/include
– Found PNG: /usr/include
– WARNING: you are using the obsolete ‘PKGCONFIG’ macro use FindPkgConfig
– Found OPENEXR: /usr/lib/libImath.so;/usr/lib/libIlmImf.so;/usr/lib/libIex.so;/usr/lib/libHalf.so;/usr/lib/libIlmThread.so
– GLUT Found
– Found Glew:
CMake Error at CMakeModules/FindPANO13.cmake:76 (MESSAGE):
libpano13 version: 2.9.18 required, 2.9.14 found
Call Stack (most recent call first):
CMakeLists.txt:235 (FIND_PACKAGE)

(This comes from the compilation of hugin.) So how to tell cmake, where to find it? Open CMakeModules/FindPANO13.cmake in an editor of your choice. Somewhere at the beginning you can find an code snippet looking similar to this one:

FIND_PATH(PANO13_INCLUDE_DIR pano13/panorama.h
/usr/local/include
/usr/include
${SOURCE_BASE_DIR}/libpano13/include
${SOURCE_BASE_DIR}/libpano
${SOURCE_BASE_DIR}
)
FIND_LIBRARY(PANO13_LIBRARIES
NAMES pano13
PATHS ${SYSTEM_LIB_DIRS}
“${PANO13_INCLUDE_DIR}/pano13/Release LIB CMD”
“${PANO13_INCLUDE_DIR}/pano13/Release CMD/Win32″
${PANO13_INCLUDE_DIR}/pano13/Release
${SOURCE_BASE_DIR}/libpano13/lib
${SOURCE_BASE_DIR}/pano13
)

As you can see, a few standard directories are searched for the panorama.h file. If for whatever reason the library cannot be found, remember the name of the include path (here: PANO13_INCLUDE_DIR) and invoke cmake like in the following example:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DPANO13_INCLUDE_DIR=/path/to/your/library/

This should work.

.



* clock project

Posted on November 4th, 2011 by Alex. Filed under Projects.


I was always fascinated by QlockTwo, but my wallet is not thick enough to shell out only $1100 for the least expensive version. It is a simple wall clock doing nothing but telling the time by illuminating letters which seem to randomly arranged in a grid. The clock updates the time every 5 minutes. If the time is e.g. 11:58 till 12:02, it shows simple “It is twelve o’clock”. Commonly if somebody is asked for the time and it is in the mentioned range, the reply would be the same: It’s twelve.

For less money QlockTwo is also available for iPad and Android operated phones and tabs. The price for the app is $0.99 plus a tab for around $400 to $500 (there are also less expensive ones, but honestly, if you have a tab, will you only use it as a clock?) sums up to around $500, which is half the price of the wall clock.

However there is one more option: Recently I got hold of a digital photo frame for around $40. Apart from photos taken from digital cameras, the idea is to generate images showing the time instead and let them run in a never ending slide show loop. So I implemented a program, generating the required images. Unfortunately the slide show mode does not allow to show the next image every 5 minutes, the closest interval is 1 minute. Hence I needed to generate 720 images for 12 hours. However, the digital photo frame shows the image for almost exactly 1 minute and transits to the next one. After the transition is completed, the countdown timer of 1 minute is restarted. The transition itself does not count. So, every transition the time was slow by round about 1.5 seconds. The transition could not be switched off. After a long trial I managed to get a very accurate timing (loosing something like 17 seconds per month), by removing and inserting certain images to compensate for the time loss during the transitions. In the end I needed 2770 files for 2 days.

However compared to the inspiring QlockTwo design, I can change the colors and even the background of the clock. Basically the options are limitless and I might add new languages in the future. Till then, I have a nice wall clock.

.



* shutdown script

Posted on September 29th, 2011 by Alex. Filed under Linux.


If computers are not in use, I would like to shut dem down automatically to save power and also to extend the lifetime of the hardware (especially mechanical HDD). Many users forget or are too lazy to shut down their machines, when they e.g. leave their office. That is why I wrote this little script that can be executed as a cronjob as root.

It will not shut down the computer, if one of the following conditions are met:

  1. There exists is a file called dontShutdown in /tmp
  2. Users are logged in
  3. Any screen sockets exist.
  4. The load on the machine is more than 20% (of one core/CPU)

You can comment/decomment the if conditions in the script accordingly. The reason to include the last condition was to ensure, that the computer is shut down, if it is idle, since I have the habit of not terminating screen sessions. However, if you e.g. download a big file in a screen session, which does not require many CPU resources, then the computer is also shut down. Similar, if you decrease the load of the CPU to such a low level that e.g. service which come sporadically into life, cause a short necessity of CPU resources, the machine is never shut down. Adjust the parameters according to you needs. After that, ensure that the script is executed periodically by e.g. putting it into the cron of the root user (here every 30 minutes):

30 * * * * /root/shutDownIfUnused.sh > /dev/null 2>&1

License

The annoying legal part: Do whatever you want with the file.

Download

.



* tar is a coward

Posted on September 6th, 2011 by Alex. Filed under Linux.


While doing some work in the console, sometimes the Linux user comes across rather curious things especially error messages. While some error messages are very cryptic and confusing resulting in a few hours spend for research, some are funny and entertaining. Most of the times it happens due to misspellings or due to some important parameters which were forgotten. For example if you like to unpack the content of a .tar.gz file, but instead of typing

tar xfvz somefile.tar.gz

your mind wanders around and finally you execute

tar cfvz somefile.tar.gz

which creates a tar archive, the resulting error message will be:

~/tmp$ tar cfvz somefile.tar.gz
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
~/tmp$

Such a coward….

.



* debian squeeze on sony c series – vpccb15fg

Posted on September 3rd, 2011 by Alex. Filed under Linux.



After my previous laptop broke, I was looking for a new one. After a not convincing chat session with Dell experts, I finally decided to go for a Sony laptop (VPCCB15FG/B).

How to install Debian Squeeze on Sony C-Series?

Step 1: Installing a minimal system

Unfortunately the kernel that is shipped with Squeeze, does not include the driver for the Ethernet card (the output of lspci including the kernel modules for the hardware is at the end of this post). Hence the “Smaller CDs” (Installing Debian GNU/Linux via the Internet) do not work. The “Small CDs” install a minimal but working Debian on the machine, so I went for this one. If the installer in one of the last steps allows you to select additional software such as Desktop System or different kind of servers, remove the selections from all entries. You will be left behind with a minimal system and a black console with a blinking cursor. If you are new to the terminal or console, simply follow the steps. If you are an advanced user, feel free to skip the elaborated texts.

Step 2: Activating the network adapter

Newer kernels include the driver that is necessary to access the Internet to download additional packets. So first you have to install several packages via the offline method. Selecting a mirror that is close should not a problem. The following packages and all its dependencies you need to select for installation: kernel-package, libncurses5-dev (if you want to use make menuconfig), and for later or if you want to use the provided .config file (refer to the end of this post) firmware-linux-nonfree and lzop. You also need the kernel sources form kernel.org. At the time of writing I used the most current version 3.0.4, so the .config file is for that version. After installing all packages via the apt-get offline method, perform the following steps:

  • copy the kernel sources/patches to /usr/src/
  • unpack the kernel sources: tar xfj linux-3.0.tar.bz2
  • unpack patches that you downloaded eventually to patch the kernel to a more current version: bunzip patch-3.0.4.bz2
  • create a link from linux to the newly created directory: ln -sv linux-3.0 linux
  • unpack (bunzip2 config-3.0.4.bz), copy the file to /usr/src/linux and rename (mv config-3.0.4 .config) it to .config (Since the file starts with a ., it is not visible by the normal ls command. Do an ls -la instead.)
  • cd /usr/src/linux
  • Apply the patch, if necessary: patch -p1 < ../patch-3.0.4
  • If you want to configure your own kernel, do a make menuconfig -j4 and make the necessary changes.
  • Execute the following commands to compile the kernel:
    • export CONCURRENCY_LEVEL="4" (This will use all 2 cores and its Hyper-threading Technology to compile the kernel, so that the compilation takes something like 5 minutes.)
    • make-kpkg kernel-image --append-to-version -1 (The last number needs to change whenever you want to compile your kernel again, in case you forgot to select a driver or functionality)
  • If you get an error, check if you installed firmware-linux-nonfree. Otherwise you can find the kernel in a .deb package format in /usr/src/
  • Install the new kernel: dpkg -i /usr/src/linux-image-3.0.4-1_3.0.4-1-10.00.Custom_amd64.deb
  • And reboot: init 6

Step 3: Installing the software

After the new kernel came up, you probably need to configure your network adapter in /etc/network/interfaces. Have a look at the example below and adapt it to your needs.


auto eth0
# for dhcp
# iface eth0 inet dhcp
# for static addresses
iface eth0 inet static
address 10.112.14.15
broadcast 255.255.255.255
netmask 255.255.255.0
gateway 10.112.14.1
# i do not want to have wake on lan and hence switch it off. Not mandatory to have it. ethtool needs to be installed separately
post-up /sbin/ethtool -s $IFACE wol d
post-down /sbin/ethtool -s $IFACE wol d

Restart the network: /etc/init.d/networking stop and immediately after that /etc/init.d/networking start.

Now you should be able to use tasksel or aptitude to select the necessary software comfortably.

Some Notes

The laptop has 2 graphics adapters: The integrated Intel HD3000 and ATI/AMD Radeon HD 6600M. Since I use Linux mainly to do work and not for fancy games, I intended to run only the power saving Intel graphics card. Compiz runs without any problems on the Intel adapter. Switching to the more powerful ATI card while the X-Server is not running, should be possible with vgaswitcheroo, but I have not tested it yet. Apart from that everything works without any problems.

In case, the kernel compilation is too complicated, you might want to consider Ubuntu instead. However in my experience Ubuntu with its bleeding edge software lacks stability. E.g. in my case Unity and its desktop crashed several times. Also Gparted crashed while it was repartitioning my hard drive. Fortunately nothing serious happened.

Files

lspci

00:00.0 Host bridge: Intel Corporation Sandy Bridge DRAM Controller (rev 09)
Kernel driver in use: agpgart-intel

00:01.0 PCI bridge: Intel Corporation Sandy Bridge PCI Express Root Port (rev 09) (prog-if 00 [Normal decode])
Kernel driver in use: pcieport

00:02.0 VGA compatible controller: Intel Corporation Sandy Bridge Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])
Kernel driver in use: i915

00:16.0 Communication controller: Intel Corporation Cougar Point HECI Controller #1 (rev 04)

00:1a.0 USB Controller: Intel Corporation Cougar Point USB Enhanced Host Controller #2 (rev 04) (prog-if 20 [EHCI])
Kernel driver in use: ehci_hcd

00:1b.0 Audio device: Intel Corporation Cougar Point High Definition Audio Controller (rev 04)
Kernel driver in use: HDA Intel

00:1c.0 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 1 (rev b4) (prog-if 00 [Normal decode])
Kernel driver in use: pcieport

00:1c.1 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 2 (rev b4) (prog-if 00 [Normal decode])
Kernel driver in use: pcieport

00:1c.2 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 3 (rev b4) (prog-if 00 [Normal decode])
Kernel driver in use: pcieport

00:1c.3 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 4 (rev b4) (prog-if 00 [Normal decode])
Kernel driver in use: pcieport

00:1d.0 USB Controller: Intel Corporation Cougar Point USB Enhanced Host Controller #1 (rev 04) (prog-if 20 [EHCI])
Kernel driver in use: ehci_hcd

00:1f.0 ISA bridge: Intel Corporation Cougar Point LPC Controller (rev 04)

00:1f.2 SATA controller: Intel Corporation Cougar Point 6 port SATA AHCI Controller (rev 04) (prog-if 01 [AHCI 1.0])
Kernel driver in use: ahci

00:1f.3 SMBus: Intel Corporation Cougar Point SMBus Controller (rev 04)
Kernel driver in use: i801_smbus

01:00.0 VGA compatible controller: ATI Technologies Inc NI Whistler [AMD Radeon HD 6600M Series] (prog-if 00 [VGA controller])
Kernel driver in use: radeon

02:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
Kernel driver in use: ath9k

03:00.0 SD Host controller: Ricoh Co Ltd Device e823 (rev 04)
Kernel driver in use: sdhci-pci

03:00.1 System peripheral: Ricoh Co Ltd Device e232 (rev 04)

04:00.0 USB Controller: NEC Corporation uPD720200 USB 3.0 Host Controller (rev 04) (prog-if 30)
Kernel driver in use: xhci_hcd

05:00.0 Ethernet controller: Atheros Communications Device 1083 (rev c0)
Kernel driver in use: atl1c

lsusb

Bus 002 Device 003: ID 045e:0745 Microsoft Corp.
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 05ca:18c0 Ricoh Co., Ltd
Bus 001 Device 004: ID 0489:e00f Foxconn / Hon Hai
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

kernel .config

This .config provides compiled-in modules for the entire hardware found in the laptop. It does not include many things that are compiled in the standard kernels such as IPv6 or other (in my case unused) protocols and file systems. Feel free to adapt this configuration file according to your needs.

.



* wifi kill switch and ifconfig wlan0 up/down

Posted on June 14th, 2011 by Alex. Filed under Linux.


To save battery power and precious runtime of a laptop, it is advisable to switch off devices that are not in use. Such a device would be the built in WIFI or WLAN adapter, hence many laptops have a hardware kill switch. However in Linux most probably the WLAN adapter is not able to reconnect to any network after the kill switch has been activated (that means the adapter has been switched off) and deactivated (WLAN adapter switched on). Instead the user has to type in ifconfig wlan0 up as root in the terminal to get things back to work.

To avoid this inconvenience and to automate the process, udev is of great help. As already described in this post and more extensively for instance on this web page, udev is a daemon running in the background, which is able to run user programs, if something happens to the e.g. hardware of the laptop. That can be a simple event of plugging in the mouse into the USB port or (as in our case discussed here) the change of the state of the kill switch.

First, we have to get to know, how to grab the kill switch event. For that execute

udevadm monitor

as root. The output will look like

root@jitu:~# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

Then you turn the kill switch and more information will be printed:

root@jitu:/home/alefel# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[1307970746.488938] change /devices/pci0000:00/0000:00:1c.5/0000:0c:00.0/ieee80211/phy0/rfkill0 (rfkill)
UDEV [1307970748.257897] change /devices/pci0000:00/0000:00:1c.5/0000:0c:00.0/ieee80211/phy0/rfkill0 (rfkill)

This means that the KERNEL and UDEV detected a change at the device /devices/pci0000:00....../rfkill0. Copy this path and paste it as a parameter to this command to get to know, what actually changes here:

root@jitu:~# udevadm info -a -p /devices/pci0000:00/0000:00:1c.5/0000:0c:00.0/ieee80211/phy0/rfkill0

Many sections are printed on the screen each starting with “looking at device …”. The most important section is the very first one. Yours will look similar to this output:

looking at device '/devices/pci0000:00/0000:00:1c.5/0000:0c:00.0/ieee80211/phy0/rfkill0':
KERNEL=="rfkill0"
SUBSYSTEM=="rfkill"
DRIVER==""
ATTR{name}=="phy0"
ATTR{type}=="wlan"
ATTR{index}=="0"
ATTR{persistent}=="0"
ATTR{state}=="1"
ATTR{claim}=="0"
ATTR{soft}=="0"
ATTR{hard}=="0"

Important is the value of ATTR{state}. On my laptop the value is 1, if the kill switch is off (and the adapter is turned on) and 2, if the kill switch is activated. You might have different values here.

Now we have to let udev know, what should be done (or which program should be executed), if the state of the kill switch is changed. Since the switch is network related, I created new rules in 70-persistent-net.rules:

root@jitu:~# anyEditorYouLike /etc/udev/rules.d/70-persistent-net.rules

Add the 2 lines in this file:

SUBSYSTEM=="rfkill", ACTION=="change", ATTR{state}=="1", ATTR{type}=="wlan", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow hotplug wlan0"
SUBSYSTEM=="rfkill", ACTION=="change", ATTR{state}=="2", ATTR{type}=="wlan", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow hotplug wlan0"

The purpose of the other ATTR values is basically to identify the device that will trigger the execution of the program. They can be found in the sections of udevadm info above. If these lines do not work, you can also try out these lines instead:

SUBSYSTEM=="rfkill", ACTION=="change", ATTR{state}=="1", ATTR{type}=="wlan", RUN+="/sbin/ifup --allow hotplug wlan0"
SUBSYSTEM=="rfkill", ACTION=="change", ATTR{state}=="2", ATTR{type}=="wlan", RUN+="/sbin/ifdown --allow hotplug wlan0"

If you turn the kill switch, the wifi interface (wlan0 in my case) is coming up or put down automatically. If not something went wrong. To support your debugging, stop the udev daemon and restart it in debugging mode:

root@jitu:~# /etc/init.dudev stop
Stopping the hotplug events dispatcher: udevd.
root@jitu:~# udevd --debug

Many lines of code will be spilled out. On top there should be a line

Jun 14 00:07:56 jitu udevd[24780]: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file

without an error. After all the initialization text has been thrown out, turn the kill switch and observe, what udev does:

Jun 14 00:08:04 jitu udevd[24780]: seq 3022 queued, 'change' 'rfkill'
Jun 14 00:08:04 jitu udevd[24780]: seq 3022 forked new worker [25359]
Jun 14 00:08:04 jitu udevd-work[25359]: seq 3022 running
Jun 14 00:08:04 jitu udevd-work[25359]: device 0xb975fc08 has devpath '/devices/pci0000:00/0000:00:1c.5/0000:0c:00.0/ieee80211/phy0/rfkill0'
Jun 14 00:08:04 jitu udevd-work[25359]: RUN '/sbin/ifup --allow hotplug wlan0' /etc/udev/rules.d/70-persistent-net.rules:18
Jun 14 00:08:04 jitu udevd-work[25359]: RUN 'socket:@/org/freedesktop/hal/udev_event' /lib/udev/rules.d/90-hal.rules:2
Jun 14 00:08:04 jitu udevd-work[25359]: '/sbin/ifup --allow hotplug wlan0' started
Jun 14 00:08:06 jitu udevd-work[25359]: '/sbin/ifup --allow hotplug wlan0' returned with exitcode 0
Jun 14 00:08:06 jitu udevd-work[25359]: passed 256 bytes to socket monitor 0xb975fc08
Jun 14 00:08:06 jitu udevd-work[25359]: passed -1 bytes to netlink monitor 0xb975fb28

If the exitcode of the executed program differs from 0, something went wrong. Try to understand the error message that is also printed out. If your rule is not executed at all, check the ATTR parameters in the rule file above.

Loading different settings depending on the SSID

For even more comfort, a network configuration should be loaded based on the SSID of the current access point. For that purpose wpa_supplicant supports ID tags for each network configuration in /etc/wpa_supplicant/wpa_supplicant.conf.

Example files:
/etc/wpa_supplicant/wpa_supplicant.conf.

ctrl_interface=/var/run/wpa_supplicant
eapol_version=2
ap_scan=1


network={
ssid="home"
key_mgmt=WPA-PSK
proto=RSN
pairwise=TKIP
group=TKIP
psk=0123456789abcdef......
priority=10
id_str="home"
}

network={
ssid="AndroidAP"
key_mgmt=WPA-PSK
proto=RSN
psk=0123456789abcdef......
priority=7
id_str="AndroidAP"
}

/etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

#-- WLAN interface
#auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#wpa-debug-level 2

# no id_str given
iface default inet dhcp

#id_str="home"
iface home inet dhcp

#id_str="AndroidAP"
iface AndroidAP inet static
address 10.112.14.101
broadcast 255.255.255.255
netmask 255.255.255.0
gateway 10.112.14.1

Do not use tabs or any other white space character before iface. It will not work otherwise which took me some time to figure that out. So whenever the WLAN adapter connects to a access point with a matching SSID, the ID tag is given to wpa_action which configures the adapter according to the settings given in interfaces. This makes the manual reconfiguring of the network adapter and the restarting of the network every time obsolete.

.



* changing gnome proxy setting in the console

Posted on May 20th, 2011 by Alex. Filed under Linux.


For someone who uses a laptop and has changing environments (e.g. home and office) in which e.g. the proxy settings differ, it is annoying to change the proxy settings every time, when the laptop is taken home or to office. Although the Network Proxy Preferences in Gnome (under System -> Preferences) support multiple locations, it is still annoying, if also other settings need to be changed along with the proxy. E.g. in my setup the laptop checks, if a second monitor is attached to the external VGA port. If so, the office environment is loaded together with the static office IP for the Ethernet adapter, the IPs for the DNS server, and the settings for the proxy. If no secondary screen is found, the laptop assumes to be in the home environment and makes the necessary changes again fully automated.

While changes of the DNS settings, the screen and the IP can be easily done through scripts which are executed as root, it is difficult to change the Gnome proxy settings in the same way. First of all each user has his own proxy settings stored in $HOME/.gconf/system/http_proxy/%gconf.xml and $HOME/.gconf/system/proxy/%gconf.xml. Secondly changing the file of the user in his home directory does not have any effect, since the changes of the file need to be communicated to the DBus. Fortunately Gnome is shipped with a program called gconftool, which allows the user to make the changes and then to inform DBus about them as well.

With gconftool -R /system/http_proxy and gconftool -R /system/proxy the current settings regarding the proxy are displayed. So, if the command sudo is used, the root user is able to read out the settings of another user. E.g.

sudo -u $USERNAME gconftool -R /system/http_proxy

With the -s parameter, the settings can be changed. If root would like to activate the proxy for a specific user, root would use

sudo -u $USERNAME gconftool -s /system/http_proxy/use_http_proxy -t bool true. The new settings can be again displayed by sudo -u $USERNAME gconftool -R /system/http_proxy executed in the same console. However if the user checks the setting in his Network Proxy Preferences in Gnome, no change happened and the new settings are not applied.

The reason is either the missing or wrong DBus Session Address, which is like a hook allowing programs to communicate with the bus. Every user has a different address to the bus. It can be displayed by executing dbus-launch in a console. So while gconftool is executed, we have to inform it, which address to use to access the bus. The following script is executed as root and changes the settings properly for a specific user.

#!/bin/bash
#– unset the proxy for gnome
USER=YOURUSERNAME

#– extract the DBus Session Address
DBUS_SESSION_BUS_ADDRESS=$(sudo -u $USER dbus-launch –autolaunch=`cat /var/lib/dbus/machine-id` | grep BUS_ADDRESS | cut -d ‘=’ -f 2-)

#– deactivate the proxy
sudo -u $USER DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gconftool -s /system/http_proxy/use_http_proxy -t bool false
sudo -u $USER DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gconftool -s /system/proxy/mode -t string direct

.



* automount via udev only

Posted on April 3rd, 2011 by Alex. Filed under Linux.


The previous solution with autofs had a big disadvantage: It could take some arbitrarily time between 2 seconds and 2 minutes till the device showed up in the list of mounted devices. Hence currently I am trying out a solution that is based on udev only.

The rules of udev allow to execute a program after the hooks etc. have been created. Such a command could look like this:
ACTION=="add", KERNEL=="sd[b-z][1-9]", DRIVERS=="sd", RUN+="/bin/mount /dev/$name"

It is pretty much self-explanatory: If the kernel detects a device that starts from sdb1 and ends at sdz9 (and all combinations of characters and numbers in between), mount is executed with the name of the detected device. E.g. the device that is plugged in is found in /dev/sdb1 (First partition, second hard disk [sda is the first hard disk]), mount /dev/sdb1 is executed. In /etc/fstab it says that /dev/sdb1 is mounted to /media/usb0

Now the devices are mounted almost instantly. Have a look at the provided example files below (They also explain what to do, if you want to execute something after the device is removed) and adapt them to your needs. Also I would recall that the command udevadm info --name=/dev/sdb --attribute-walk (executed as root) is a great help in finding the correct KERNEL, ATTRS, etc. for your own rules. As desired by myself, the devices are not umounted automatically after a timeout. If you want that, you should have a look at autofs.

If it does not work at all, it is a good idea to study the log file of udev. To convince udev to be more verbose, set udev_log to "debug" in /etc/udev/udev.conf and check the log by tail -f /var/log/syslog. After that, plug in the device. A lot of text will be spilled out, so concentrate your search on lines like

Apr 3 17:51:49 jitu udevd-work[25302]: ‘/bin/mount /media/sd’ started
Apr 3 17:51:49 jitu udevd-work[25302]: ‘/bin/mount /media/sd’ returned with exitcode 0

If the exitcode is not equal 0, then some error happened during the execution of mount itself. Check it manually by typing the command (e.g. /bin/mount /media/sd) to find the corresponding error message. If you cannot find such a line, your attributes in the rules-file are not correct, since the rule is not applied and executed at all and so is the mount command.

The configuration files:

.



RSS Feeds:

Search:


Pages:

Categories:

Archives: