2017-01-18更新:这个日志(2016-09-01)有些内容已经过时了,要自己注意一下。

确保你的K2已经刷上breed并能刷上第三方固件!

准备

准备工作:安装virtualbox虚拟机,安装lubuntu16.04 i386系统,确定虚拟系统能正常上网,顺便给虚拟机共享实体机的一个目录,方便文件传送。
进入虚拟系统,并打开终端(Tips:可以关闭lightdm,在tty终端下运行,节省内存)

     
     
1
2
     
     
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install git autoconf automake bison build-essential flex gawk gettext gperf libtool pkg-config zlib1g-dev libgmp3-dev libmpc-dev libmpfr-dev texinfo python-docutils mc autopoint -y

     
     
1
2
3
4
5
6
7
     
     
sudo passwd root
#输入root密码2次
su
#输入root密码,切换到root用户
cd /opt
git clone https://bitbucket.org/padavan/rt-n56u.git
#等N分钟下载源码
     
     
1
2
3
4
5
6
     
     
===这里是编译mips工具===
cd /opt/rt-n56u/toolchain-mipsel
./clean_sources
#这里很快就完成
./build_toolchain
#这里要等几十分钟具体看机器,最后会显示ALL DONE相关信息

这样子,前期工作完成,开始修正padavan固件适配k2的问题。

一:修正K2的GPIO

这里的K2硬件版本为A2
Reset:GPIO 1

LED颜色 GPIO lo hi
8
11
10

编辑 /opt/rt-n56u/trunk/configs/boards/RT-AC54U/board.h文件
并把内容改为如下,注意没有数字参数的请确定前面是“#undef”,否则编译时报错。

     
     
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
     
     
/* ASUS RT-AC54U */
#define BOARD_PID "RT-AC54U"
#define BOARD_NAME "RT-AC54U"
#define BOARD_DESC "ASUS RT-AC54U Wireless Router"
#define BOARD_VENDOR_NAME "ASUSTek Computer Inc."
#define BOARD_VENDOR_URL "http://www.asus.com/"
#define BOARD_MODEL_URL "http://www.asus.com/Networking/RTAC54U/"
#define BOARD_BOOT_TIME 25
#define BOARD_FLASH_TIME 60
#undef BOARD_GPIO_BTN_RESET
#define BOARD_GPIO_BTN_WPS 1
#undef BOARD_GPIO_LED_ALL
#define BOARD_GPIO_LED_WIFI 11
#define BOARD_GPIO_LED_POWER 8
#undef BOARD_GPIO_LED_LAN
#define BOARD_GPIO_LED_WAN 10
#undef BOARD_GPIO_LED_USB
#undef BOARD_GPIO_LED_ROUTER
#undef BOARD_GPIO_PWR_USB
#define BOARD_HAS_5G_11AC 1
#define BOARD_NUM_ANT_5G_TX 2
#define BOARD_NUM_ANT_5G_RX 2
#define BOARD_NUM_ANT_2G_TX 2
#define BOARD_NUM_ANT_2G_RX 2
#define BOARD_NUM_ETH_LEDS 0
#define BOARD_HAS_EPHY_L1000 0
#define BOARD_HAS_EPHY_W1000 0

然后保存文件

二:调用原厂无线参数

把/opt/rt-n56u/trunk/configs/boards/RT-AC54U目录下”SingleSKU”开头的文件全删除
并编辑/opt/rt-n56u/trunk/configs/boards/RT-AC54U/kernel-3.4.x.config文件
查找并修改为如下内容(主要修正是删除#号,或者将is not set改为=y或=n)

     
     
1
2
3
4
5
6
7
8
9
10
     
     
CONFIG_RT_SINGLE_SKU=n
CONFIG_RT2860V2_AP_GREENAP=y
CONFIG_INTERNAL_PA_INTERNAL_LNA=n
CONFIG_INTERNAL_PA_EXTERNAL_LNA=n
CONFIG_EXTERNAL_PA_EXTERNAL_LNA=y
CONFIG_MT76X2_AP_GREENAP=y
CONFIG_MT76X2_AP_INTERNAL_PA_INTERNAL_LNA=n
CONFIG_MT76X2_AP_INTERNAL_PA_EXTERNAL_LNA=n
CONFIG_MT76X2_AP_EXTERNAL_PA_EXTERNAL_LNA=y
CONFIG_RALINK_UART_BRATE=57600

然后保存文件

三:修正WAN/LAN顺序

默认情况下,WAN口会变成LAN4口,LAN4口会变成WAN口
编辑/opt/rt-n56u/trunk/configs/boards/RT-AC54U/kernel-3.4.x.config文件
查找WAN=0并修改为如下内容

     
     
1
2
3
4
5
     
     
CONFIG_RAETH_ESW_PORT_WAN=4
CONFIG_RAETH_ESW_PORT_LAN1=3
CONFIG_RAETH_ESW_PORT_LAN2=2
CONFIG_RAETH_ESW_PORT_LAN3=1
CONFIG_RAETH_ESW_PORT_LAN4=0

然后保存文件

四:汉化

(有能力的自己汉化也行,我这借用hiboy的汉化)
下载hiboy的固件,并用7-zip打开trx固件文件,提取里面的/www/EN.dict,编辑EN.dict,修改第二,三行内容如下,

     
     
1
2
     
     
LANG_RU=简体中文
LANG_EN=English

并另存为RU.dict文件,替换/opt/rt-n56u/trunk/user/www/dict/RU.dict文件

再编辑/opt/rt-n56u/trunk/user/www/Makefile文件,查找并将RU=后面的内容改为”简体中文”

     
     
1
     
     
echo "LANG_RU=简体中文" >> $(ROMFS_DIR)/www/EN.header

然后保存文件

五:默认配置(可选)

给路由设置个人的默认配置
编辑/opt/rt-n56u/trunk/user/shared/defaults.c
使路由器不用ISP的dns,用第三方dns

     
     
1
2
3
     
     
{wan_dnsenable_x ", "0 " },
{ "wan_dns1_x ", "223.5.5.5 " },
{ "wan_dns2_x ", "119.29.29.29 " },

承接上面,如果电脑将路由器当用dns服务器,则进入路由页面
http://192.168.1.1/Advanced_DHCP_Content.asp
“DHCP服务器”
自定义配置文件 “dnsmasq.conf”
(配置路由里的dnsmasq,如googlevideo用sni,则添加address=/.googlevideo.com/xxx.xx.x.x)

自定义配置文件 “hosts”
(配置路由里的hosts)

路由默认登陆ip

     
     
1
2
     
     
{ "lan_ipaddr", "192.168.1.1" },
{ "lan_netmask", "255.255.255.0" },

dhcp客户机分配数量

     
     
1
2
     
     
{ "dhcp_start", "192.168.1.101" },
{ "dhcp_end", "192.168.1.250" },

关闭telnet开启ssh

     
     
1
2
     
     
{ "telnetd", "0" },
{ "sshd_enable", "1" },

然后保存文件

编辑/opt/rt-n56u/trunk/user/shared/defaults.h

下面内容主要是配置2G/5G无线区码,默认SSID名字(ABC_x),默认密码(1234567890),默认路由管理员密码(admin8888),默认时区,默认NTP时间服务器

     
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
     
     
#define SYS_USER_ROOT "admin"
#define SYS_GROUP_ROOT "root"
#define SYS_USER_NOBODY "nobody"
#define SYS_GROUP_NOGROUP "nogroup"
#define DEF_WLAN_2G_CC "CN"
#define DEF_WLAN_5G_CC "CN"
#define DEF_WLAN_2G_SSID "ABC_2016"
#define DEF_WLAN_5G_SSID "ABC_2016_5G"
#define DEF_WLAN_2G_GSSID "ABC_GUEST"
#define DEF_WLAN_5G_GSSID "ABC_GUEST_5G"
#define DEF_WLAN_2G_PSK "1234567890"
#define DEF_WLAN_5G_PSK "1234567890"
#define DEF_ROOT_PASSWORD "admin8888"
#define DEF_SMB_WORKGROUP "WORKGROUP"
#define DEF_TIMEZONE "CST-8"
#define DEF_NTP_SERVER0 "ntp1.aliyun.com"
#define DEF_NTP_SERVER1 "time.nist.gov"

编辑/opt/rt-n56u/trunk/user/scripts/profile文件内容如下
当进入ssh时,文字不再黑白了,有色彩

     
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
     
     
# /etc/profile
# If running interactively, then
if [ "$PS1" ] ; then
export PATH= '/opt/usr/sbin:/opt/usr/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin'
export HOSTNAME=`/bin/hostname`
export TERMINFO=/usr/share/terminfo
export TERM=xterm
export LD_LIBRARY_PATH=/lib:/etc_ro/lib:/opt/lib
export LANG= 'en_US.UTF-8'
export LC_ALL= 'en_US.UTF-8'
export PS1= '\[\033[35;1m\]\u\[\033[0m\]@\[\033[31;1m\]\h \[\033[32;1m\]$PWD\[\033[0m\] [\[\033[35m\]\$\[\033[0m\]] '
fi;
alias ls= 'ls --color=auto -F'
alias dir= 'ls --color=auto -lAhF'
alias ll= 'ls --color=auto -lAhFe'
[ -r /opt/etc/profile ] && . /opt/etc/profile

开始编译固件!(上面的全部操作都是在切换到root用户操作的,下面也是一样。)
编辑/opt/rt-n56u/trunk/.config文件内容如下(这个文件是隐藏的),我这个配置是禁用usb相关东西的。

如果你的文件路径没有按照本教程,则要注意下面的“CONFIG_TOOLCHAIN_DIR=/opt/rt-n56u/toolchain-mipsel”改为你自己的路径

     
     
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
     
     
### Target Vendor/Product (support only Ralink RT3883/MT7620/MT7621/MT7628)
CONFIG_VENDOR=Ralink
CONFIG_PRODUCT=MT7620
### Target ProductID (board select, max 12 symbols)
CONFIG_FIRMWARE_PRODUCT_ID= "RT-AC54U"
### Linux kernel and toolchain
CONFIG_LINUXDIR=linux-3.4.x
CONFIG_TOOLCHAIN_DIR=/opt/rt-n56u/toolchain-mipsel
############################################################
### Linux kernel configuration
############################################################
### Build ROOTFS_IN_RAM firmware mode (kernel+initramfs).
### Decreased firmware size, but more RAM used, slow boot.
### Also allow build image for load w/o flash from UART console
#CONFIG_FIRMWARE_TYPE_ROOTFS_IN_RAM=y
### Force MT7620 CPU clock to 600MHz (override Uboot settings)
#CONFIG_FIRMWARE_CPU_600MHZ=y
### Enable MT7620 CPU sleep mode (downclock to 200MHz on idle)
CONFIG_FIRMWARE_CPU_SLEEP=y
### Kernel driver select for WiFi AP 2.4GHz
### 2.7 = MT7620 v2.7.2.0
### 3.0 = MT7620 v3.0.4.0
CONFIG_FIRMWARE_WIFI2_DRIVER=2.7
### Kernel driver select for WiFi AP 5GHz
### 3.0 = MT7612E v3.0.4.0
CONFIG_FIRMWARE_WIFI5_DRIVER=3.0
### Enable IPv6 support
CONFIG_FIRMWARE_ENABLE_IPV6=y
### Enable USB support
#CONFIG_FIRMWARE_ENABLE_USB=y
### Enable NTFS filesystem support via Paragon "ufsd" driver. ~0.4MB
#CONFIG_FIRMWARE_ENABLE_UFSD=y
### Enable FAT/FAT32 filesystem support. ~0.1MB
#CONFIG_FIRMWARE_ENABLE_FAT=y
### Enable exFAT (FAT/FAT32 too) filesystem support. ~0.12MB
#CONFIG_FIRMWARE_ENABLE_EXFAT=y
### Enable EXT2 filesystem support. ~0.1MB
#CONFIG_FIRMWARE_ENABLE_EXT2=y
### Enable EXT3 filesystem support. ~0.2MB
#CONFIG_FIRMWARE_ENABLE_EXT3=y
### Enable EXT4 (EXT3/2 too) filesystem support. ~0.4MB
#CONFIG_FIRMWARE_ENABLE_EXT4=y
### Enable XFS filesystem support. ~0.6MB
#CONFIG_FIRMWARE_ENABLE_XFS=y
### Enable FUSE (filesystems in userspace) support. ~0.1MB
#CONFIG_FIRMWARE_ENABLE_FUSE=y
### Enable swap files/partitions support. ~0.05MB
#CONFIG_FIRMWARE_ENABLE_SWAP=y
### Include UVC camera modules. ~0.2MB
#CONFIG_FIRMWARE_INCLUDE_UVC=y
### Include USB-HID modules. ~0.2MB
#CONFIG_FIRMWARE_INCLUDE_HID=y
### Include USB-Serial modules (e.g. pl2303). ~0.03MB
#CONFIG_FIRMWARE_INCLUDE_SERIAL=y
### Include USB-Audio modules ~0.46MB
#CONFIG_FIRMWARE_INCLUDE_AUDIO=y
### Include network QoS scheduling modules. ~0.2MB
CONFIG_FIRMWARE_INCLUDE_QOS=y
### Include IMQ module for shapers (a bit of performance degradation). ~0.02MB
#CONFIG_FIRMWARE_INCLUDE_IMQ=y
### Include IFB module for shapers. ~0.03MB
#CONFIG_FIRMWARE_INCLUDE_IFB=y
### Include IPSet utility and kernel modules. ~0.4MB
CONFIG_FIRMWARE_INCLUDE_IPSET=y
### Include NFSv3 server. ~0.6MB
#CONFIG_FIRMWARE_INCLUDE_NFSD=y
### Include NFSv3 client. ~0.5MB
#CONFIG_FIRMWARE_INCLUDE_NFSC=y
### Include CIFS (SMB) client. ~0.2MB
#CONFIG_FIRMWARE_INCLUDE_CIFS=y
############################################################
### Userspace configuration
############################################################
### Include WebUI international resources. Increased firmware size
#CONFIG_FIRMWARE_INCLUDE_LANG_BR=y
#CONFIG_FIRMWARE_INCLUDE_LANG_CZ=y
#CONFIG_FIRMWARE_INCLUDE_LANG_DA=y
#CONFIG_FIRMWARE_INCLUDE_LANG_DE=y
#CONFIG_FIRMWARE_INCLUDE_LANG_ES=y
#CONFIG_FIRMWARE_INCLUDE_LANG_FI=y
#CONFIG_FIRMWARE_INCLUDE_LANG_FR=y
#CONFIG_FIRMWARE_INCLUDE_LANG_NO=y
#CONFIG_FIRMWARE_INCLUDE_LANG_PL=y
CONFIG_FIRMWARE_INCLUDE_LANG_RU=y
#CONFIG_FIRMWARE_INCLUDE_LANG_SV=y
#CONFIG_FIRMWARE_INCLUDE_LANG_UK=y
### Include NTFS-3G FUSE driver (instead of Paragon "ufsd"). ~0.4MB
#CONFIG_FIRMWARE_INCLUDE_NTFS_3G=y
### Include LPR printer daemon. ~0.12MB
#CONFIG_FIRMWARE_INCLUDE_LPRD=y
### Include USB-over-Ethernet printer daemon. ~0.05MB
#CONFIG_FIRMWARE_INCLUDE_U2EC=y
### Include "tcpdump" utility. ~0.6MB
#CONFIG_FIRMWARE_INCLUDE_TCPDUMP=y
### Include "hdparm" utility (allow set HDD spindown timeout and APM). ~0.1MB
#CONFIG_FIRMWARE_INCLUDE_HDPARM=y
### Include "parted" utility (allow make GPT partitions). ~0.3MB
#CONFIG_FIRMWARE_INCLUDE_PARTED=y
### Include SMB (and WINS) server. ~1.5MB
#CONFIG_FIRMWARE_INCLUDE_SMBD=y
### Include WINS server only. ~0.4MB
#CONFIG_FIRMWARE_INCLUDE_WINS=y
### Include syslog for SMB and WINS server. ~0.3MB
#CONFIG_FIRMWARE_INCLUDE_SMBD_SYSLOG=y
### Include FTP server. ~0.2MB
#CONFIG_FIRMWARE_INCLUDE_FTPD=y
### Include alternative L2TP control client RP-L2TP. ~0.1MB
#CONFIG_FIRMWARE_INCLUDE_RPL2TP=y
### Include EAP-TTLS and EAP-PEAP authentication support. openssl ~1.2MB, wpa_supplicant +0.04MB
CONFIG_FIRMWARE_INCLUDE_EAP_PEAP=y
### Include HTTPS support for DDNS client. openssl ~1.2MB
CONFIG_FIRMWARE_INCLUDE_DDNS_SSL=y
### Include HTTPS support. openssl ~1.2MB
CONFIG_FIRMWARE_INCLUDE_HTTPS=y
### Include sftp-server. openssl ~1.2MB, sftp-server ~0.06MB
CONFIG_FIRMWARE_INCLUDE_SFTP=y
### Include dropbear SSH. ~0.3MB
CONFIG_FIRMWARE_INCLUDE_DROPBEAR=y
### Make the dropbear symmetrical ciphers and hashes faster. ~0.06MB
CONFIG_FIRMWARE_INCLUDE_DROPBEAR_FAST_CODE=y
### Include OpenSSH instead of dropbear. openssl ~1.2MB, openssh ~1.0MB
#CONFIG_FIRMWARE_INCLUDE_OPENSSH=y
### Include OpenVPN. IPv6 required. openssl ~1.2MB, openvpn ~0.4MB
CONFIG_FIRMWARE_INCLUDE_OPENVPN=y
### Include Elliptic Curves (EC) to openssl library. ~0.1MB
CONFIG_FIRMWARE_INCLUDE_OPENSSL_EC=y
### Include "openssl" executable for generate certificates. ~0.4MB
CONFIG_FIRMWARE_INCLUDE_OPENSSL_EXE=y
### Include xUPNPd IPTV mediaserver. ~0.3MB
#CONFIG_FIRMWARE_INCLUDE_XUPNPD=y
### Include Minidlna UPnP mediaserver. ~1.6MB
#CONFIG_FIRMWARE_INCLUDE_MINIDLNA=y
### Include Firefly iTunes mediaserver. ~1.0MB
#CONFIG_FIRMWARE_INCLUDE_FIREFLY=y
### Include ffmpeg 0.11.x instead of 0.6.x for Minidlna and Firefly. ~0.1MB
#CONFIG_FIRMWARE_INCLUDE_FFMPEG_NEW=y
### Include Transmission torrent. openssl ~1.2MB, transmission ~1.5MB
#CONFIG_FIRMWARE_INCLUDE_TRANSMISSION=y
### Include Transmission-Web-Control (advanced WebUI). ~0.8MB
#CONFIG_FIRMWARE_INCLUDE_TRANSMISSION_WEB_CONTROL=y
### Include Aria2 download manager. openssl ~1.2MB, aria2 ~3.5MB
#CONFIG_FIRMWARE_INCLUDE_ARIA=y
### Include Aria2 WEB control. ~0.7MB
#CONFIG_FIRMWARE_INCLUDE_ARIA_WEB_CONTROL=y

所有配置都好了,现在开始编译

     
     
1
2
3
4
5
     
     
cd /opt/rt-n56u/trunk
./clear_tree
#每次编译都要先运行这句
./build_firmware
#开始编译了

去看个电影动画什么的,等待结果,如果不出错,最后会显示信息包括固件大小,名字,位置等
最后固件生成在/opt/rt-n56u/trunk/images下.trx扩展名的。

后续升级源码

     
     
1
2
3
4
5
6
7
8
9
10
11
     
     
git pull
#如果toolchain-mipsel有改过,则要重新编译
cd /opt/rt-n56u/toolchain-mipsel
/clean_sources
/clean_toolchain
/build_toolchain
#再编译更新过的固件
cd /opt/rt-n56u/trunk
./clear_tree
./build_firmware

心得

1 有时候自己的sh脚本运行不了,要用dos2unix转一下文件才行

2 nvram参数的作用过程(用adbyby作例子)
先命名nvram参数,写好运行/停止adbyby的脚本,在services.c里定义通过nvram参数值来如何运行脚本。
最后就是在asp页面里改变nvram参数值
可以参考aria相关脚本和参数

3 去广告时要开启cron功能,因为adbyby的透明代理有时候会掉

4 hosts方式去广告
http://www.right.com.cn/forum/thread-184121-1-1.html

5 脚本运行adbyby
在/etc/storage/下新建adbyby.sh内容如下

     
     
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
     
     
#!/bin/sh
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
TAG= "adbyby" # iptables tag
dir_crond= "/etc/storage/cron/crontabs"
username=$(whoami)
urla= "https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/video.txt"
dladb= "https://raw.githubusercontent.com/adbyby/Files/master/7620n.tar.gz"
func_create_config()
{
cd /tmp
wget --continue --no-check-certificate -s -q -T 3 $urla
if [ "$?" == "0" ] ; then
echo "[$LOGTIME] update.adbyby.com have no problem."
wget -q --no-check-certificate $dladb -P /tmp/
tar -xzf /tmp/7620n.tar.gz -C /tmp/
rm -rf /tmp/7620n.tar.gz
chmod 777 /tmp/bin/adbyby
logger -t "【$TAG】" "['$LOGTIME'] 下载成功."
else
echo "[$LOGTIME] update.adbyby.com have problem."
logger -t "【$TAG】" "['$LOGTIME'] 下载失败,检查网络."
fi
}
func_start()
{
if [ ! -d "/tmp/bin" ] ; then
func_create_config
fi
if [ ! -z "`pidof " $TAG "`" ] ; then
echo "$TAG" still running
exit 1;
else
/tmp/bin/adbyby >/dev/null 2>&1 &
if iptables -t nat -nL --line-numbers | grep -q "$TAG"; then
echo "$TAG" still running!; else
iptables -t nat -N "$TAG"
iptables -t nat -A "$TAG" -p tcp --dport 80 -j REDIRECT --to-ports 8118
iptables -t nat -I PREROUTING -j "$TAG";
echo start "$TAG"
logger -t "【$TAG】" "['$LOGTIME'] 启动成功."
fi
if cat "$dir_crond"/ "$username" | grep -q "$TAG"; then
echo already had 8118 cron;
else
echo '30 * * * * /bin/sh /etc/storage/adbyby.sh re8118' >> "$dir_crond"/ "$username"
echo add 8118 cron
logger -t "【$TAG】" "['$LOGTIME'] 添加守护8118端口cron."
sleep 1
fi
fi
}
func_re8118()
{
if [ ! -z "`pidof " $TAG "`" ] ; then
if iptables -t nat -nL --line-numbers | grep -q "$TAG"; then
echo "$TAG" still running!
logger -t "【$TAG】" "['$LOGTIME'] 转发8118端口还在.";
else
iptables -t nat -N "$TAG"
iptables -t nat -A "$TAG" -p tcp --dport 80 -j REDIRECT --to-ports 8118
iptables -t nat -I PREROUTING -j "$TAG";
logger -t "【$TAG】" "['$LOGTIME'] 重新转发8118端口."
fi
else
logger -t "【$TAG】" "['$LOGTIME'] 没运行不用转发8118端口."
echo not need re8118
exit 1;
fi
}
func_stop()
{
if [ ! -z "`pidof " $TAG "`" ] ; then
iptables-save -c | grep -v "$TAG" | iptables-restore -c
logger -t "【$TAG】" "['$LOGTIME'] 移除8118端口转发."
killall -9 adbyby >/dev/null 2>&1
echo close "$TAG"
logger -t "【$TAG】" "['$LOGTIME'] 关闭$TAG."
if cat "$dir_crond"/ "$username" | grep -q "$TAG"; then
sed -i '/adbyby/d' "$dir_crond"/ "$username"
echo remove 8118 cron
logger -t "【$TAG】" "['$LOGTIME'] 移除守护8118端口cron."
sleep 2;
else
exit 1;
fi
else
echo "$TAG" not running!
exit 1;
fi
}
case "$1" in
start)
func_start $2
;;
re8118)
func_re8118
;;
stop)
func_stop
;;
*)
echo "Usage: $0 {start|re8118|stop}"
exit 1
;;
esac
exit 0
     
     
1
2
3
     
     
#运行mtd_storage.sh save来保存文件
#可以在“在 WAN 上行/下行启动后执行:”添加
sh /etc/storage/adbyby.sh start

几个值得参考的帖子
http://www.right.com.cn/Forum/thread-191833-1-1.html
http://www.right.com.cn/Forum/thread-161324-1-1.html
http://www.right.com.cn/Forum/thread-188188-1-1.html
http://www.right.com.cn/Forum/thread-190224-1-1.html
http://www.612459.com/luyouqi/2372.html
http://www.right.com.cn/forum/thread-193826-1-1.html
https://github.com/cappiewu/rt-n56u/commits/master

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐