抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

简介:主要针对梅林系统路由器的开机启动问题

完整策略

梅林系统每次开机只会保留/jeffs/当中内容,所以一定要把自己想要运行的脚本放在该文件夹下。但是,由于路由器有点,所以建议单独插一个U盘把真正的执行文件放在U盘里,然后利用/jeffs/当中的脚本来执行一个U盘中的脚本,从而避免多次修改/jeffs/文件。也就是最终的执行策略如下:

  1. 插入U盘
  2. 在U盘中创建脚本
  3. /jeffs/中创建或修改间接脚本文件,具体参考下面的路由器脚本

路由器脚本

关于梅林系统的脚本,官方给了一个说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
** User scripts **
These are shell scripts that you can create, and which will be run when
certain events occur. Those scripts must be saved in /jffs/scripts/ ,
so, JFFS must be enabled, as well as the option to use custom
scripts and configs. This can be configured under Administration -> System.
Available scripts:

* ddns-start: Script called at the end of a DDNS update process.
This script is also called when setting the DDNS type
to "Custom". The script gets passed the WAN IP as
an argument.
When handling a "Custom" DDNS, this script is also
responsible for reporting the success or failure
of the update process. See the Custom DDNS section
below for more information.
* dhcpc-event: Called whenever a DHCP event occurs on the WAN
interface. The type of event (bound, release, etc...)
is passed as an argument.
* firewall-start: Firewall is started (filter rules have been applied)
The WAN interface will be passed as argument (for
example. "eth0")
* init-start: Right after jffs is mounted, before any of the services
get started
* nat-start: nat rules (i.e. port forwards and such) have been applied
(nat table)
* openvpn-event: Called whenever an OpenVPN server gets
started/stopped, or an OpenVPN client connects to a
remote server. Uses the same syntax/parameters as
the "up" and "down" scripts in OpenVPN.
* post-mount: Just after a partition is mounted
* pre-mount: Just before a partition is mounted. Be careful with
this script. This is run in a blocking call and will
block the mounting of the partition for which it is
invoked till its execution is complete. This is done so
that it can be used for things like running e2fsck on the
partition before mounting. This script is also passed the
device path being mounted as an argument which can be
used in the script using $1.
* qos-start: Called after both the iptables rules and tc configuration
are completed for QoS. This script will be passed an
argument, which will be "init" (when QoS is being
initialized and it has setup the tc classes) or
"rules" (when the iptables rules are being setup).
* services-start: Initial service start at boot
* services-stop: Services are stopped at shutdown/reboot
* unmount: Just before unmounting a partition. This is a blocking
script, so be careful with it. The mount point is passed
as an argument to the script.
* wan-start: WAN interface just came up (includes if it went down and
back up). The WAN unit number will be passed as argument
(0 = primary WAN)

Don't forget to set them as executable:

chmod a+rx /jffs/scripts/*

And like any Linux script, they need to start with a shebang:

#!/bin/sh

根据这个说明,我们知道

  1. 不存在的脚本可以自己创建
  2. 脚本文件是放在/jffs/scripts/下的
  3. 脚本文件是以#!/bin/sh开头的
  4. 脚本的权限为chmod a+rx
  5. 如果要把真正的执行脚本放在U盘中,建议把间接脚本内容放在post-mount