ubuntu - 在 upstart conf 中执行条件可以吗?

标签 ubuntu upstart

我有一个应用程序更新服务,它使用它的 conf 同步到服务器:

start on started engine
stop on stopped engine or firmware_update_mode

现在,我在 /var/run/engine/wifi 获得设备上的 wifi 状态状态向上/向下。我现在正试图了解让这个应用程序更新服务仅在上行 wifi 上运行并在下行 wifi 上停止它的正确方法。当然,它只会在引擎运行时运行。因此,它应该作为条件执行运行,即

启动引擎 wifi up,停止wifi down。

app-update.conf 是放置此类条件执行的正确位置(在 wifi up 上运行,在 wifi down 上停止)?

最佳答案

添加另一个工作:

start on file EVENT=modify FILE=/var/run/engine/wifi or starting app-update

task

script
    if grep -q "^up" /var/run/engine/wifi && \
       initctl status engine | grep -q "start/running"
    then
        start app-update
    elif grep -q "^down" /var/run/engine/wifi; then
        stop app-update
    fi
end script

这将在 app-update 首次启动时检查 wifi 是否已启动,并在 wifi 启动或关闭时启动和停止 app-update。

不幸的是,这有点复杂,因为 Upstart 没有状态支持(只有事件)。

关于ubuntu - 在 upstart conf 中执行条件可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28109131/

相关文章:

logging - Upstart 控制台输出不起作用

linux - 启动终端并在重启后从 systemd 执行脚本

ubuntu - 使用 Chef 时主管打开文件限制不会改变

c++ - 如何交叉编译成ARM9板子?

linux - 如何调试间歇性失败的 upstart 脚本?

node.js - CentOS 中 nodejs 守护进程的 Upstart 脚本不起作用(启动时崩溃)

linux - Upstart 不会开始我的工作

c++ - 在共享库中查找引用 undefined symbol 的源文件

php - 在 php apache 中创建一个文件夹

ruby - ri 有空文件 – Ubuntu 11.10, Ruby 1.9