[SOLVED] UDEV-Triggered scripts delay disc mounting
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    UDEV-Triggered scripts delay disc mounting

    I've been working on my Fedora 12 media server to get a DVD ripping bash script to execute automatically when a DVD is mounted by the system. I solved that problem in another thread with this UDEV rule:
    Code:
    SUBSYSTEM=="block", KERNEL=="sr0", ENV{DKD_MEDIA_AVAIABLE}=="1", RUN+="/usr/local/bin/detectdisc"
    The only caveat is that the rule file name had to have a high number so as execute last - "99-my.rule".

    However, it has a strange behavior that I cannot overcome which prevents the the setup working - despite my UDEV rule being number 99 and applied lastly, the optical Disc will not actually mount until my script is finished executing. I tried adding a sleep command to the top of my script but that only delays mounting further.

    As an experiment I wrote a simple script...
    Code:
    #!/bin/bash
    sleep 30
    ...and had that executed by my UDEV rule. After inserting a disc the system would wait exactly 30 seconds before mounting the disc. So I tried calling a second script from the first and put a sleep 5 command at the top of the second script to give the system time to mount the disc, but that method still delays disc mounting 5 seconds until the second script is finished executing.

    I've tried launching the script in a new shell using /bin/bash/ -c myscript.sh but with the same effect.

    In short, I need to find a way to get the script to run after the disc has mounted because it simply won't work otherwise.

  2. #2
    Join Date
    Jan 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: UDEV-Triggered scripts delay disc mounting

    OK, I found a solution that works and it requires a two-tier approach.

    The UDEV rule must first execute a "trigger" script which in turn executes my DVD ripping script along with an exit command to kill the initiating process. It goes like this:

    UDEV Rule
    Code:
    SUBSYSTEM=="block", KERNEL=="sr0", ENV{DKD_MEDIA_AVAIABLE}=="1", RUN+="/usr/local/bin/trigger.sh"
    trigger.sh script
    Code:
    #!/bin/bash
    ripdvd.sh & exit
    It's the "& exit" that makes it all work. I also added a "sleep 5" to the start of my ripdvd.sh script to give time for the disc to mount.

    I also considered adding the "& exit" line to the UDEV rule to to cut out the middle man...
    Code:
    SUBSYSTEM=="block", KERNEL=="sr0", ENV{DKD_MEDIA_AVAIABLE}=="1", RUN+="/usr/local/bin/detectdisc & exit"
    ...but that did not work either.

Similar Threads

  1. init scripts - are not triggered on bootup.
    By masionas in forum Using Fedora
    Replies: 7
    Last Post: 13th August 2005, 06:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •