Upstart calling script (for inserted USB-drive)

前端 未结 2 689
旧巷少年郎
旧巷少年郎 2021-02-02 03:05

I know that Ubuntu (and Fedora) uses Upstart istead of the classical System V init daemon (SysVinit).

I would like to know how to detect when a USB-drive has been insert

2条回答
  •  星月不相逢
    2021-02-02 04:03

    In Ubuntu 9.10 and newer Upstart has some udev capabilities through the upstart-udev-bridge service.

    #thumbdrive_special.conf
    start on block-device-added
    
    task
    
    script
       if [ `blkid $DEV` -eq "YOUR-THUMBDRIVES-UUID" ]; then
          /home/you/bin/thumbdrive_special $DEV
       fi
    end script
    

    I love how simple and elegant upstart can be. However, a DBus solution might be better if less elegant. With a DBus solution you could pop up notifications to the user and provide easy user control.

提交回复
热议问题