转自:http://wiki.openwrt.org/doc/techref/initscripts
创建文件:/etc/init.d/example
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
START=10
STOP=15
start() {
echo start
# commands to launch application
}
stop() {
echo stop
# commands to kill application
}
-
START=10
- this means the file will be symlinked as /etc/rc.d/S10example - in other words, it will start after the init scripts with START=9 and below, but before START=11 and above. -
STOP=15
- this means the file will be symlinked as /etc/rc.d/K15example - this means it will be stopped after the init scripts with STOP=14 and below, but before STOP=16 and above. This is optional.
如果程序需要依赖其他服务,例如网卡,则需要在网卡之后启动,即START的数值要相对于网卡的值大,具体打多少需要试验下。
然后执行命令
/etc/init.d/example enable并重新启动路由器