2017-05-29 74 views
-1

以下是/etc/udev/rules.d/10-autodvd.rules我的規則文件光盤的udev規則無法運行腳本

SUBSYSTEM=="block", KERNEL=="sr0", ENV{ID_CDROM_MEDIA_DVD}=="1", ACTION=="change", RUN+="/usr/local/bin/makemkv.sh sr0" 
SUBSYSTEM=="block", KERNEL=="sr1", ENV{ID_CDROM_MEDIA_DVD}=="1", ACTION=="change", RUN+="/usr/local/bin/makemkv.sh sr1" 
SUBSYSTEM=="block", KERNEL=="sr2", ENV{ID_CDROM_MEDIA_DVD}=="1", ACTION=="change", RUN+="/usr/local/bin/makemkv.sh sr2" 
SUBSYSTEM=="block", KERNEL=="sr3", ENV{ID_CDROM_MEDIA_DVD}=="1", ACTION=="change", RUN+="/usr/local/bin/makemkv.sh sr3" 
SUBSYSTEM=="block", KERNEL=="sr4", ENV{ID_CDROM_MEDIA_DVD}=="1", ACTION=="change", RUN+="/usr/local/bin/makemkv.sh sr4" 

這似乎是真打還是錯過實際運行腳本,有沒有更好的方法來做到這一點?

回答

1

Udev按字典排序規則文件,並且在應用規則時,ID_CDROM_MEDIA_DVD變量可能尚未設置。 systemd udev的默認安裝就是這種情況。 ID_CDROM*變量在60-cdrom_id.rules中設置,所以您應該重命名您的規則文件,在此之後進行排序。

請注意,您不應該使用RUN + =鍵啓動長時間運行的程序。

RUN{type} 
    [...] 
     This can only be used for very short-running 
     foreground tasks. Running an event process for 
     a long period of time may block all further 
     events for this or a dependent device. 

     Starting daemons or other long-running 
     processes is not appropriate for udev; the 
     forked processes, detached or not, will be 
     unconditionally killed after the event handling 
     has finished. 

你的規則可以寫成一個規則:

SUBSYSTEM=="block", KERNEL=="sr[0-4]", ENV{ID_CDROM_MEDIA_DVD}=="1", ACTION=="change", RUN+="/usr/local/bin/makemkv.sh %k"