1

I'm trying to write a udev rule on my Beaglebone White that runs when a Pantech UML 295 finishes booting.

When using udevadm monitor --environment I get the following final output which I would like to base the rule on:

UDEV [3163.454297] add /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-
1:1.0/net/eth1 (net)
ACTION=add
DEVPATH=/devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1:1.0/net/eth1
ID_BUS=usb
ID_MODEL=PANTECH_UML295
ID_MODEL_ENC=PANTECH\x20UML295
ID_MODEL_ID=6064
ID_REVISION=0228
ID_SERIAL=Pantech__Incorporated_PANTECH_UML295_UML295692146818
ID_SERIAL_SHORT=UML295692146818
ID_TYPE=generic
ID_USB_DRIVER=cdc_ether
ID_USB_INTERFACES=:020600:0a0000:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Pantech__Incorporated
ID_VENDOR_ENC=Pantech\x2c\x20Incorporated
ID_VENDOR_ID=10a9
IFINDEX=6
INTERFACE=eth1
SEQNUM=1151
SUBSYSTEM=net
SYSTEMD_ALIAS=/sys/subsystem/net/devices/eth1
TAGS=:systemd:
USEC_INITIALIZED=3163023666

My udev rule version 1:

ENV{ID_BUS}=="usb", SUBSYSTEM=="net", RUN+="/home/root/rebootInternetConnection.sh", ENV{ID_MODEL}=="PANTECH_UML295", ACTION=="add", INTERFACE=="eth1", ENV{ID_USB_DRIVER}=="cdc_ether"

and version 2:

ACTION=="add", SUBSYSTEM=="net", RUN+="/home/root/rebootInternetConnection.sh"

Version 2 is a stripped down version which should be ran more than once, but doesn't get ran at all. Version 1 uses environment variables which I'm not sure whether or not the rule has access to.

To clarify: the rule doesn't get ran at all, and the shell script has echos which should show up. My rule is in the /etc/udev/rules.d/ directory with name 10-local.rules.

EDIT

Here are some more non-functional rules, placed in /etc/udev/rules.d/81-pantech.rules:

ACTION=="add", SUBSYSTEM=="net", ATTR{idVendor}=="10a9", RUN+="/home/root/reboot
InternetConnection.sh"

SUBSYSTEM=="net", ATTR{idVendor}=="10a9", ATTR{idProduct}=="6064", RUN+="/home/ro
ot/rebootInternetConnection.sh"

ACTION=="add", SUBSYSTEM=="hid", RUN+="/home/root/rebootInternetConnection.sh"

ACTION=="add", SUBSYSTEM=="usb", RUN+="echo foo > /tmp/foo"

SUBSYSTEM=="usb", ATTR{product}=="PANTECH UML295", RUN +="echo foo > /tmp/foo"

ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="PANTECH UML295", RUN+="/home/ro
ot/rebootInternetConnection.sh"

When I run:

udevadm test /devices/platform/omap/musb-ti81xx/musb-hdrc.1/u 

it returns the last couple of lines as:

run: 'echo foo > /tmp/foo'
run: 'echo foo > /tmp/foo'
run: 'echo foo > /tmp/foo'
run: '/home/root/rebootInternetConnection.sh'

Is there a case where the rules will add to the RUN+=, but don't get used?

8
  • 1
    Does it run if you use something even simpler like ls? Also, do you actually have a /home/root directory? Root's $HOME is usually /root. Commented Sep 4, 2013 at 18:42
  • "Version 1 uses environment variables which I'm not sure whether or not the rule has access to." -- I believe that is correct, you don't get any ENV stuff for "add" events. Your echo's are not going to show up anywhere, but you can use the logger command to pipe stuff to syslog. Commented Sep 4, 2013 at 19:15
  • Possible answer here: udev-rule-is-not-being-used. Commented Sep 4, 2013 at 19:26
  • @terdon When I pwd I get /home/root. Commented Sep 4, 2013 at 19:27
  • @terdon ls Doesn't run either. Commented Sep 4, 2013 at 19:32

1 Answer 1

0

Not sure what changed, but the rule is now being used in the file /etc/udev/rules.d/81-pantech.rules

One possibility is the missing /run/udev/rules.d/ directory. When I ran

udevadm test /devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1

I got a line reporting that the directory was missing. I found this command through this guide: http://weininger.net/how-to-write-udev-rules-for-usb-devices/

mkdir /run/udev/rules.d/

Another possibility is me manually running the udev daemon with

/lib/udev/udevd --debug

This is my final rule:

ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="PANTECH UML295", RUN+="/home/root/rebootInternetConnection.sh"

ACTION=="add", SUBSYSTEM=="net", ATTR{idVendor}=="10a9", RUN+="/home/root/rebootInternetConnection.sh"

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.