可以通过连接的设备触发upstart脚本吗?
当连接设备(外部磁盘)时,如何指定“启动”条件以运行upstart脚本?
是。 读一下man upstart-udev-bridge
。 基本上任何可以触发udev
脚本的东西都可以触发Upstart事件。 在Upstart Cookbook的Bridges部分还有更多内容 。
在你的情况下,我们讨论的是一个块设备,所以这里是deft_code 的StackOverflowpost的一个例子:
#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
另一种途径是使用udev在插入内容时触发运行脚本 。 这可能是任何事情,包括运行upstart命令。
Upstart有一个mounted
事件,但这只是在启动mountall调用的后面。 我认为这没什么用处。