Starting a while ago, my script for uploading firmware to my printer stopped working when I inserted the USB cable, and had to be run manually afterwards. Tried modifying the script, so it appends "ls -la /dev/usb" to a file (/var/log/usbdebug) . When I inserted the cable, it didn't add anything to the file (= /dev/usb did not exist). Then afterwards I ran the script manually, and this time /dev/usb and /dev/usb/lp0 showed up in the file. It seems like udev / hotplug runs the script prior to making the device node. Is this a bug, or have I missed a config option I can set to make it create the device node first? Reproducible: Always Steps to Reproduce: Here is the script for uploading the firmware: (Is there another way to get hotplug/udev to do this)? jupiter ~ # cat /etc/hotplug/usb/hplj1000 #!/bin/bash # This script was written to auto-load the HP Laserjet 1000 drivers. echo -n `date` >> /var/log/usbprinter echo -n " HP Laserjet 1000 USB Firmware loading... " >> /var/log/usbprinter cat /lib/firmware/sihp1000.dl > /dev/usb/lp0 && echo "[ OK ]" >> /var/log/usbprinter && exit; echo "[ FAILED ]" >> /var/log/usbprinter
Use dev.d for your script, not the hotplug location. See the udev documentation for how dev.d works for what you need to do for this. Putting this file in the hotplug directory tree almost guarantees that this will not work properly, as those scripts do not know when the device node is created, only when the device is seen by the kernel (two different things).
It might be a stupid question .... but how exactly do I do this?
Read the /usr/share/doc/udev-051/RFC-dev.d.gz file for details.