How do I get rc.inet1 to run when usb dev plugged in?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do I get rc.inet1 to run when usb dev plugged in?
Hi slackers,
I'm trying to get slack to configure my usb1000 ethernet device.
So far I've got it to load the right module (asix) automatically when the dev is plugged in. And made a udev rule to make sure it gets the if number that I want a'la:
Udev does have an option to run a command specified in the device rule. That might be what you're looking for. From my favorite udev rules howto:
Quote:
Running external programs upon certain events
Yet another reason for writing udev rules is to run a particular program when a device is connected or disconnected. For example, you might want to execute a script to automatically download all of your photos from your digital camera when it is connected.
Do not confuse this with the PROGRAM functionality described above. PROGRAM is used for running programs which produce device names (and they shouldn't do anything other than that). When those programs are being executed, the device node has not yet been created, so acting upon the device in any way is not possible.
The functionality introduced here allows you to run a program after the device node is put in place. This program can act on the device, however it must not run for any extended period of time, because udev is effectively paused while these programs are running. One workaround for this limitation is to make sure your program immediately detaches itself.
Here is an example rule which demonstrates the use of the RUN list assignment:
KERNEL=="sdb", RUN+="/usr/bin/my_program
"When /usr/bin/my_program is executed, various parts of the udev environment are available as environment variables, including key values such as SUBSYSTEM. You can also use the ACTION environment variable to detect whether the device is being connected or disconnected - ACTION will be either "add" or "remove" respectively.
udev does not run these programs on any active terminal, and it does not execute them under the context of a shell. Be sure to ensure your program is marked executable, if it is a shell script ensure it starts with an appropriate shebang (e.g. #!/bin/sh), and do not expect any standard output to appear on your terminal.
So you could try adding RUN+="/etc/rc.inet1" to the end of the rule for your device.
If you plug in a USB device that has a driver in the kernel, then the default UDEV rules will load the driver and run "/etc/rc.d/rc.inet1 <interfacename>_start" if you plug it in. No custum UDEV rules required.
For instance, after I installed a package for the rt73 driver (RaLink based USB wireless dongle) and added configuration for the rausb0 device in rc.inet1.conf , plugging in the USB device was enough to bring the wireless interface up and configure it automatically.
It appears as tough rc.inet1 is not running when I plug in the device BUT...don't believe everything you don't see. /var/log/messages shows me that in fact rc.inet1 does run:
Jan 16 09:36:48 charger kernel: usb 1-4: new high speed USB device using ehci_hcd and address 4
Jan 16 09:36:48 charger kernel: usb 1-4: configuration #1 chosen from 1 choice
Jan 16 09:36:49 charger kernel: eth1: register 'asix' at usb-0000:00:1a.7-4, ASIX AX88178 USB 2.0 Ethernet, 00:12:17:f2:21:0c
Jan 16 09:36:49 charger logger: /etc/rc.d/rc.inet1: /sbin/dhcpcd -d -t 30 eth1
Jan 16 09:36:49 charger kernel: eth1: link down
Jan 16 09:36:49 charger kernel: ADDRCONF(NETDEV_UP): eth1: link is not ready
Jan 16 09:36:51 charger kernel: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
Jan 16 09:36:51 charger kernel: eth1: link up, 100Mbps, full-duplex, lpa 0x41E1
The problem seems to be that the link takes a couple of seconds to come up and rc.inet1 runs before the interface is ready.
How to fix?
I was thinking maybe add some sleeps to rc.inet1 but this just doesn't sit well with me. Is there some hook I can use to prevent rc.inet1 from running until the interface is ready?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.