如何在openwrt中自动启动应用程序?
How to auto start an application in openwrt?
我创建了一个 shell 具有必要的功能,例如
开始()
停止()
重启()
但是我的文件没有在启动时启动。
我在 "ubuntu" 中使用 update-rc.d 命令将此文件添加到自动启动应用程序列表中。并在开机时成功启动。
但是在"openwrt"中我看到了一个enable函数。任何人都知道如何使用此启用功能或是否有任何类似的命令,如 update-rc.d in "openwrt"
/etc/init.d/ - 目录将自动读取并搜索引导功能或 START STOP。
在启动时启动。
boot() {
echo boot
# commands to run on boot
}
START-位置然后开始
STOP-定位然后停止
START=10
STOP=15
start() {
echo start
# commands to launch application
}
stop() {
echo stop
# commands to kill application
}
已编辑:
在/etc/rc中编译了公共目录文件,这些文件将在引导时启动。
启用您的功能:/etc/init.d/your_script.sh enable
在这里您可以找到更多关于引导的信息http://wiki.openwrt.org/doc/techref/process.boot
确保脚本的第一行显示为:
#!/bin/sh /etc/rc.common
将脚本复制到 /etc/init.d/
目录
确保执行位已打开
chmod +x /etc/init.d/<your script>
启用脚本
/etc/init.d/<your script> enable
您的脚本现在应该在 /etc/rc.d/
中有一个符号链接
ls -lh /etc/rc.d | grep <your script>
确认您的初始化脚本已启用:
/etc/init.d/<your script> enabled && echo on
如果此命令 returns on
,那么你就完成了。如果此命令没有 return 任何内容,那么您的脚本未启用。以下是已启用的脚本示例:
root@OpenWrt:~# /etc/init.d/system enabled && echo on
on
我已经在 OpenWrt Chaos Calmer 15.05 上测试了这些步骤,但它应该适用于早期版本。祝你好运!
如果您需要 运行 您的命令仅在系统启动时(刚启动后):
编辑 /etc/rc.local 这是你的文件。
默认情况下它只包含注释(指定的驱动程序,但在某些早期版本中也是如此):
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
您可以在此处添加命令。
我的例子:
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
if grep -q '/dev/sdb2' /proc/swaps ; then swapoff /dev/sda2 ; fi
comgt -s /etc/config/init-script.comgt
我创建了一个 shell 具有必要的功能,例如 开始() 停止() 重启()
但是我的文件没有在启动时启动。
我在 "ubuntu" 中使用 update-rc.d 命令将此文件添加到自动启动应用程序列表中。并在开机时成功启动。
但是在"openwrt"中我看到了一个enable函数。任何人都知道如何使用此启用功能或是否有任何类似的命令,如 update-rc.d in "openwrt"
/etc/init.d/ - 目录将自动读取并搜索引导功能或 START STOP。 在启动时启动。
boot() {
echo boot
# commands to run on boot
}
START-位置然后开始
STOP-定位然后停止
START=10
STOP=15
start() {
echo start
# commands to launch application
}
stop() {
echo stop
# commands to kill application
}
已编辑:
在/etc/rc中编译了公共目录文件,这些文件将在引导时启动。
启用您的功能:/etc/init.d/your_script.sh enable
在这里您可以找到更多关于引导的信息http://wiki.openwrt.org/doc/techref/process.boot
确保脚本的第一行显示为:
#!/bin/sh /etc/rc.common
将脚本复制到
/etc/init.d/
目录确保执行位已打开
chmod +x /etc/init.d/<your script>
启用脚本
/etc/init.d/<your script> enable
您的脚本现在应该在
中有一个符号链接/etc/rc.d/
ls -lh /etc/rc.d | grep <your script>
确认您的初始化脚本已启用:
/etc/init.d/<your script> enabled && echo on
如果此命令 returns
on
,那么你就完成了。如果此命令没有 return 任何内容,那么您的脚本未启用。以下是已启用的脚本示例:root@OpenWrt:~# /etc/init.d/system enabled && echo on on
我已经在 OpenWrt Chaos Calmer 15.05 上测试了这些步骤,但它应该适用于早期版本。祝你好运!
如果您需要 运行 您的命令仅在系统启动时(刚启动后): 编辑 /etc/rc.local 这是你的文件。
默认情况下它只包含注释(指定的驱动程序,但在某些早期版本中也是如此):
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
您可以在此处添加命令。
我的例子:
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
if grep -q '/dev/sdb2' /proc/swaps ; then swapoff /dev/sda2 ; fi
comgt -s /etc/config/init-script.comgt