how to set "usbconfig set_config 1" at boot?

12.0-RELEASE and I'm struggling to find a way to do usbconfig set_config 1 at boot. Besides having a script that runs every time the servers comes up, what's the proper way of doing this?
 
Why exactly do you need it?

Usually /etc/rc.local works for situations like this. But there might be better solutions (devd(8) for example) depending on what the command is for.
 
I have this:

Code:
ugen1.4: <TP-LINK USB 10/100 LAN> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0210 
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x2357 
  idProduct = 0x0602 
  bcdDevice = 0x2000 
  iManufacturer = 0x0001  <TP-LINK>
  iProduct = 0x0002  <USB 10/100 LAN>
  iSerialNumber = 0x0003  <503EAAACB692>
  bNumConfigurations = 0x0002

that needs set_config 1.

I tried devd with:
Code:
notify 100 {
        match "system"          "USB";
        match "subsystem"       "DEVICE";
        match "type"            "ATTACH";
        match "vendor"          "0x2357";
        match "product"          "0x0602";
        action "usbconfig -d $cdev set_config 1";
};
but it only works when attaching, not when the device is already attached and I reboot the server.

I guess I can stick with /etc/rc.local but I just wanted to know if there's a proper way of handling this situation
 
but it only works when attaching, not when the device is already attached and I reboot the server.
The attaching is done during boot, and the setting is fairly specific to this USB device, so that should be the best place for it.

The issue with rc.local is that it's only executed during boot. If you later on remove and reinsert the device rc.local will not get executed.
 
In my setup the following devd config works:

Code:
#action for Lenovo Thinkpad USB LAN adapter
notify 100 {
    match "system"        "USB";
    match "subsystem"    "DEVICE";
    match "type"        "ATTACH";
        match "vendor"          "0x17ef";
        match "product"         "0x7205";
        action "/usr/sbin/usbconfig -d $ugen set_config 1";
};

I found out that the action command should use $ugen instead of $cdev.
 
Back
Top