LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   make hotplug run a script on detect (https://www.linuxquestions.org/questions/linux-software-2/make-hotplug-run-a-script-on-detect-276914/)

bobbens 01-12-2005 10:29 AM

make hotplug run a script on detect
 
How would i get around to making my external hdd to automatically mount when detected (connected via firewire). I have written the scripts already and they work perfectly, but how would i get around to making it automatic? Do i just have to add a line in some hotplug configuration file or something? Thanks.

barryman_5000 01-12-2005 12:38 PM

The easiest method would be to edit your startup scripts for debian. I assume that hotplug is done in a high sequence number.

Simply make a file in the /etc/init.d directory containing something along the lines of:

mount /dev/sda1 /mnt/exthd

Set that file as executable:

chmod +x file

Then you run update-rc.d like so:

update-rc.d file defaults

That should do it for you. I wouldn't touch the hotplug script as it is rather annoying scripting. This way you can edit this script to test if mount returns an error or not and display a message accordingly. But that is complicated and gl if you want to do that.

bobbens 01-12-2005 12:59 PM

Yeah i have the file as executable and the mount command with which uses quite a few options. I would rather make hotplug run the script, because i try to keep this external hard drive off as much as possible (so it can't get damaged) since it is my backup drive. I was thinking of making my scripts run when it detects the drive and depending whether it is sda or sdb it will mount it with my proper script, since i sometimes hook up a flashdisk or a mp3 player and it turns into sdb instead of sda. It probably uses the lines in lsusb, but i don't know where to make it so that in the case the usb line corresponds to the hdd it automatically mounts it using the proper letter sda or sdb, if the latter is too complicated i can just make it attempt to mount both so i'll have it mounted for sure. You seem to know how to do this with hotplug, where should i start looking? Thanks

barryman_5000 01-12-2005 01:45 PM

well if it is a firewire device then perhaps you can edit the /etc/hotplug/ieee1394.agent script. Just match up the $VENDOR_ID's so that

if ["$VENDOR_ID" = "myvencor"]
do mount here
fi

just add that under the error handing Vendor_id line. This is a pretty big hack but it should work fine . . . . I haven't tried it, but good luck.

You can find your vendor's id via the /sys file system. Gl with that too.

bobbens 01-13-2005 11:16 AM

Could "ST320082" be the vendor id? I looked around /sys and found the hdd, but instead of a vendor_id file i just saw a vendor file, which is the one above. Could this be the vendor id or do i have to keep on looking? The ieee1394 id is "0050770e00071002:0:0", it could also be it, not sure though. I think it would probably work better if i put it in the add) section, just gotta be sure of the vendor id. Which one do you think it is? Thanks.

barryman_5000 01-13-2005 11:42 AM

most likely that first one.


All times are GMT -5. The time now is 10:50 PM.