I do not recommend doing frequent writes to this area, as it will prematurely wear out the flash chip. This is a good place to put files that are written once like scripts or kernel modules, or that rarely get written to. Do not put files that get constantly written to (such as high activity logfiles) - store these on a USB disk instead. Replacing a worn out USB flash disk is much cheaper than replacing the whole router if flash sectors get worn out - they have a limited number of write cycles.
我不建议经常向 JFFS 分区写入数据,这会使路由器的闪存过早报废,JFFS 分区适合存入如脚本或内核模块等写入量很小的文件,如果你要不断地存储数据(比如大量日志文件)我建议存放到 U盘 上,虽然两者写入量都是有限的,但更换 U盘 要比更换路由器闪存芯片成本更低。
你尝试一下将任意脚本放到/opt/etc/init.d/ 中,并且以 S 开头
When a USB storage device is inserted into the router’s USB port, the rc system daemon mounts the partition and checks for the existence of an asusware/.asusrouter script on the mount point. If it exists, the asusware folder is then symlinked to /tmp/opt (and also /opt) and the script is executed. Since this is all open source, you can find the relevant code in the mount_partition function in release/src/router/rc/usb.c.
当 U 盘插入路由器后,rc 系统守护进程将挂载 U 盘,并检查 U 盘 asusware 文件夹下是否存在名为 .asusrouter 的脚本文件,如果存在将会把 asusware 文件夹链接为 /tmp/opt(和 /opt),并且运行脚本。因为是开源固件,可以在源代码 release/src/router/rc/usb.c 的 mount_partition 函数中找到相关信息。
Put the commands you wish to execute in asusware/.asusrouter on your USB storage device. Like any shell script, make sure it has #!/bin/sh as its first line and that the file uses UNIX line endings. The filesystem can be anything supported by the kernel – ext2, ext3 or fat. If you are using a filesystem that implements Linux permissions (such as ext2 or ext3), be sure to set the script as executable.
将你的命令保存到 U盘 asusware 目录下的 .asusrouter 文件中,和任何 shell 脚本一样,确保脚本第一行内容为 #!/bin/sh,并且以 UNIX 作为换行符,内核支持 ext2、ext3 或 fat 格式的 U 盘,如果使用 Linux 的 ext2 或 ext3 文件系统,请确保脚本拥有执行权限。
One caveat when running network programs (like DHCP forwarder or mDNS repeater) is that you need to wait until everything has been initialized. ASUS does that by polling the success_start_service NVRAM variable with this bash snippet:复制代码
- i=0
- while [ $i -le 20 ]; do
- success_start_service=`nvram get success_start_service`
- if [ "$success_start_service" == "1" ]; then
- break
- fi
- i=$(($i+1))
- echo "autorun APP: wait $i seconds...";
- sleep 1
- done
运行和网络有关的脚本,需要等待路由器所有程序初始化完成。因此华硕使用如下命令保证这一点。
这段命令大意是:不断查询程序是否初始化完成,如果没有完成就等待,如果完成了就运行接下来的命令。
Jack 发表于 2017-5-25 19:32
本教程重在寻找过程,如果你在意最终结果,请直接看本文最后一段脚本。
在几天前,我看到了这篇文章《ac68 ...
x6d 发表于 2017-5-27 08:58
楼主你好,按照你的方法,
#!/bin/sh
Jack 发表于 2017-5-27 16:57
感谢你认真看完我的教程。
首先请你尝试在没有 U 盘的情况下用 telnet 或者 SSH 下输入这个命令看看是否 ...
x6d 发表于 2017-5-28 04:53
Jack您好,首先非常感谢您,我做了测试, SSH下输入 arp -s ... 是成功的, /opt/.asusrouter 也是成功 ...
yancao 发表于 2017-6-6 10:15
大神,你做好文件我们下载,电脑不会保存什末格式的?
bjb05 发表于 2017-6-7 10:09
感谢大神分享,思路很清晰。我有个想让路由在晚上低功率工作的想法,我用的是ac68u,辐射(据说)并不高, ...
Jack 发表于 2017-6-7 17:17
实现你的思路需要两点
第一,脚本需要可以计时,因此必须长期占用内存,不退出,这可能会干扰性能,严重 ...
bjb05 发表于 2017-6-7 10:49
无线排程功能是那个schedule吗,看到了但没想通怎么实现
bjb05 发表于 2017-6-7 17:09
感谢大神分享,思路很清晰。我有个想让路由在晚上低功率工作的想法,我用的是ac68u,辐射(据说)并不高, ...
Jack 发表于 2017-5-25 22:50
警告信息
此教程可能会被一些坏人利用,使用华硕、Asuswrt-Merlin 路由器的人请小心!
leoeos 发表于 2018-2-13 15:51
大神你好,看完了这个篇幅,按照您的方法做了,但是好像没作用
最新版固件自启动机制不同了
zhhjohnny 发表于 2018-2-13 21:48
大神你好,我现在的固件版本是3.0.0.4.384_20308 ,设备是RT-AC86U,请问哪个版本的固件可以自启脚本? ...
欢迎光临 华硕网络产品技术交流平台 (https://www.52asus.com/) | Powered by Discuz! X3.4 |