Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Perform an action when network cable unplugged (and back in again): have udev call you



On Wed, 13 Jun 2012 21:05:29 +0900, Darren Cook <darren@example.com> wrote:

> Interesting idea... but how do I know if udev gets an event?

Have udev call you. 

Browse the *.rules files /etc/udev/rules.d/ (at least that's 
where they are in Centos 5). The grammar for udev rules has 
changed much over the years. It can be difficult finding 
documentation that matches the version of udev that you're using. 
Be prepared to fumble about and futz with things to workaround 
bad or wrong version documentation. After you figure out the 
right conditions, your code can be executed with the RUN or 
PROGRAM things. Udev rules look something like the following. 

[jep@centos5 ~]$ cat /etc/udev/rules.d/60-net.rules
ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"
[jep@centos5 ~]$ 

or look at the PROGRAM stuff in the following: 

SUBSYSTEM=="tty", BUS=="usb", SYSFS{idProduct}=="1234", SYSFS{idVendor}=="5678", PROGRAM="/etc/udev/rules.d/persistent-tty-namer $SYSFS{serial} $SYSFS{bInterfaceNumber}", SYMLINK+="%c"

There's much that can be done with udev. 



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links