老毛子 小米 Mini Padavan固件[脚本备份]
封尘的小米Mini 刷了 Padavan 固件后很好用,现在备份一下 固件里面的脚本,以备不时只需。
固件
[2015-12-24]RT-AC54U-GPIO-30-xiaomimini-128M_3.4.3.9-097-12-24
运行路由器初始化之前
- #!/bin/sh
- ### Custom user script for tuning router before start
- ########################################################
- ### tune linux kernel
- ########################################################
- # backlog for UNIX sockets
- echo 64 > /proc/sys/net/unix/max_dgram_qlen
- # igmp
- echo 30 > /proc/sys/net/ipv4/igmp_max_memberships
- # arp
- echo 1 > /proc/sys/net/ipv4/conf/all/arp_announce
- echo 1 > /proc/sys/net/ipv4/conf/default/arp_announce
- # neigh ipv4
- echo 256 > /proc/sys/net/ipv4/neigh/default/gc_thresh1
- echo 1024 > /proc/sys/net/ipv4/neigh/default/gc_thresh2
- echo 2048 > /proc/sys/net/ipv4/neigh/default/gc_thresh3
- # ipv6
- if [ -d /proc/sys/net/ipv6 ] ; then
- echo 256 > /proc/sys/net/ipv6/neigh/default/gc_thresh1
- echo 1024 > /proc/sys/net/ipv6/neigh/default/gc_thresh2
- echo 2048 > /proc/sys/net/ipv6/neigh/default/gc_thresh3
- echo 16384 > /proc/sys/net/ipv6/route/max_size
- fi
- # reverse-path filter
- echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
- echo 1 > /proc/sys/net/ipv4/conf/eth2/rp_filter
- # conntrack
- echo 0 > /proc/sys/net/netfilter/nf_conntrack_checksum
- echo 1 > /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal
- echo 300 > /proc/sys/net/netfilter/nf_conntrack_generic_timeout
- echo 1800 > /proc/sys/net/netfilter/nf_conntrack_tcp_timeout_established
- echo 30 > /proc/sys/net/netfilter/nf_conntrack_icmp_timeout
- echo 50 > /proc/sys/net/netfilter/nf_conntrack_udp_timeout
- # panic
- echo 1 > /proc/sys/kernel/panic
- echo 1 > /proc/sys/kernel/panic_on_oops
- echo 0 > /proc/sys/vm/panic_on_oom
运行路由器启动后
- #!/bin/sh
- ### Custom user script
- ### Called after router started and network is ready
- ### Example - load ipset modules
- #modprobe ip_set
- #modprobe ip_set_hash_ip
- #modprobe ip_set_hash_net
- #modprobe ip_set_bitmap_ip
- #modprobe ip_set_list_set
- #modprobe xt_set
- ### 创建子程序脚本
- /etc/storage/script2_script.sh
- /etc/storage/script3_script.sh
- ### SD卡挂载
- /sbin/automount.sh mmcblk0p1 AiDisk_01
- ### 运行脚本1
- sleep 10
- /etc/storage/script1_script.sh
- /etc/storage/ez_buttons_script.sh 3 &
- logger -t "运行路由器启动后" "脚本完成"
- kmsserver()
- {
- if [ -s "/usr/bin/vlmcsd" ] ;then
- cat > "/tmp/vlmcsd.ini" <<-\EOF
- #开头的数字符号(#)或分号(;)的每一行被视为注释;删除(;)启用指定选项。
- #ePID/HwId设置为Windows显式
- 55c92734-d682-4d71-983e-d6ec3f16059f = 06401-00206-271-392041-03-1033-9600.0000-3622014 / 01 02 03 04 05 06 07 08
- #ePID设置为Office2010(包含Visio和Project)显式
- 59a52881-a989-479d-af46-f275c6370663 = 06401-00096-199-496023-03-1033-9600.0000-3622014
- #ePID设置为Office2013(包含Visio和Project)显式
- 0ff1ce15-a989-479d-af46-f275c6370663 = 06401-00206-234-409313-03-1033-9600.0000-3622014
- #使用自定义TCP端口
- ;Port = 1688
- #监听所有IPv4地址(默认端口1688)
- ;Listen = 0.0.0.0:1688
- #监听所有IPv6地址(默认端口1688)
- ;Listen = [::]:1688
- #程序启动时随机ePIDs(只有那些未显式指定的)
- ;RandomizationLevel = 1
- #在ePIDs中使用特定区域 (1033 = 美国英语),即使ePID是随机的
- ;LCID = 1033
- #设置最多4个同时工作(分叉进程或线程)
- ;MaxWorkers = 4
- #闲置30秒后断开用户
- ;ConnectionTimeout = 30
- #每次请求后立即断开客户端
- ;DisconnectClientsImmediately = yes
- #写一个pid文件(包含vlmcsd的进程ID的文件)
- ;PidFile = /var/run/vlmcsd.pid
- #写日志到/var/log/vlmcsd.log
- ;LogFile = /var/log/vlmcsd.log
- #创建详细日志
- ;LogVerbose = true
- #设置激活间隔2小时
- ;ActivationInterval = 2h
- #设置更新间隔7天
- ;RenewalInterval = 7d
- #运行程序的用户为vlmcsduser
- ;user = vlmcsduser
- #运行程序的组为vlmcsdgroup
- ;group = vlmcsdgroup
- #禁用或启用RPC的NDR64传输语法(默认启用)
- ;UseNDR64 = true
- #禁用或启用RPC的绑定时间特性协商(默认启用)
- ;UseBTFN = true
- EOF
- chmod 777 "/tmp/vlmcsd.ini"
- /usr/bin/vlmcsd -i /tmp/vlmcsd.ini -l /tmp/vlmcsd.log &
- computer_name=`nvram get computer_name`
- sed -Ei '/_vlmcs._tcp/d' /etc/storage/dnsmasq/dnsmasq.conf
- echo "srv-host=_vlmcs._tcp,$computer_name,1688,0,100" >> /etc/storage/dnsmasq/dnsmasq.conf
- restart_dhcpd
- fi
- }
- #kmsserver
- # Office手动激活命令:
- # cd C:\Program Files\Microsoft Office\Office15
- # cscript ospp.vbs /sethst:192.168.1.1
- # cscript ospp.vbs /act
- # cscript ospp.vbs /dstatus
- # windows手动激活命令
- # slmgr.vbs /upk
- # slmgr.vbs /skms 192.168.1.1
- # slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
- # slmgr.vbs /ato
- # slmgr.vbs /xpr
- # key查看
- # cat /etc/storage/key
按WPS / FN 运行按钮脚本
- #!/bin/sh
- ### Custom user script
- ### Called on WPS or FN button pressed
- ### $1 - button param
- [ -x /opt/bin/on_wps.sh ] && /opt/bin/on_wps.sh $1 &
- #copyright by hiboy
- [ -f /tmp/button_script.lock ] && exit 0
- touch /tmp/button_script.lock
- # 按钮名称可自定义
- nvram set button_script_1_s="ADbyby"
- nvram set button_script_2_s="SS"
- case "$1" in
- 1)
- # 按钮①子程序 名称可自定义
- button1=`nvram get button_script_1_s`
- logger -t "【按钮①】" "$button1"
- apply=`nvram get button_script_1`
- # 按钮①状态0时执行以下命令
- if [ "$apply" = 0 ]; then
- nvram set button_script_1="1"
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- PIDS=$(ps | grep "/tmp/adbyby" | grep -v "grep" | wc -l)
- if [ "$port" = 0 ] && [ "$PIDS" = 0 ]; then
- logger -t "【按钮①】" "添加ADbyby转发规则、启动ADbyby"
- rm -f /tmp/cron_adb.lock
- /tmp/adbyby >/dev/null 2>&1 &
- sleep 2
- /tmp/sh_adb8118.sh A &
- nvram set button_script_1="1"
- rm -f /tmp/cron_adb.lock
- fi
- fi
- # 按钮①状态1 执行以下命令
- if [ "$apply" = 1 ]; then
- nvram set button_script_1="0"
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- PIDS=$(ps | grep "/tmp/adbyby" | grep -v "grep" | wc -l)
- if [ "$port" -ge 1 ] && [ "$PIDS" != 0 ]; then
- logger -t "【按钮①】" "关闭ADbyby转发规则、关闭ADbyby"
- touch /tmp/cron_adb.lock
- /tmp/sh_adb8118.sh D &
- sleep 2
- killall -15 adbyby
- killall -9 adbyby
- nvram set button_script_1="0"
- touch /tmp/cron_adb.lock
- fi
- fi
- if [ ! -s "/tmp/adbyby" ]; then
- logger -t "【按钮①】" "找不到adbyby文件,请检查配置是否启动"
- /tmp/sh_adb8118.sh D &
- killall -15 adbyby
- killall -9 adbyby
- fi
- rm -f /tmp/button_script.lock
- /etc/storage/ez_buttons_script.sh 3 &
- ;;
- 2)
- # 按钮②子程序
- button2=`nvram get button_script_2_s`
- logger -t "【按钮②】" "$button2"
- apply=`nvram get button_script_2`
- shadowsockssh="/tmp/AiDisk_00/shadowsocks/shadowsocks"
- # 按钮②状态0 执行以下命令
- if [ "$apply" = 0 ]; then
- nvram set button_script_2="1"
- PROCESS=$(ps | grep "ss-redir" | grep -v "grep")
- if [ -z "$PROCESS" ] && [ -s "/tmp/AiDisk_00/shadowsocks/shadowsocks" ]; then
- logger -t "【按钮②】" "启动shadowsocks进程"
- rm -f /tmp/cron_ss.lock
- $shadowsockssh off_on
- rm -f /tmp/cron_ss.lock
- nvram set button_script_2="1"
- fi
- fi
- # 按钮②状态1时执行以下命令
- if [ "$apply" = 1 ]; then
- nvram set button_script_2="0"
- PROCESS=$(ps | grep "ss-redir" | grep -v "grep")
- if [ ! -z "$PROCESS" ] && [ -s "/tmp/AiDisk_00/shadowsocks/shadowsocks" ]; then
- logger -t "【按钮②】" "关闭shadowsocks进程"
- touch /tmp/cron_ss.lock
- $shadowsockssh off_on
- touch /tmp/cron_ss.lock
- nvram set button_script_2="0"
- fi
- fi
- if [ ! -s "/tmp/AiDisk_00/shadowsocks/shadowsocks" ]; then
- logger -t "【按钮②】" "opt缺少/tmp/AiDisk_00/shadowsocks/shadowsocks文件"
- logger -t "【按钮②】" "请检查配置是否启动shadowsocks"
- logger -t "【按钮②】" "请更新opt文件夹,检查U盘文件和Entware设置"
- fi
- rm -f /tmp/button_script.lock
- /etc/storage/ez_buttons_script.sh 3 &
- ;;
- 3)
- # 按钮状态检测子程序
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- if [ "$port" -ge 1 ]; then
- nvram set button_script_1="1"
- else
- nvram set button_script_1="0"
- fi
- PROCESS=$(ps | grep "ss-redir" | grep -v "grep")
- if [ -z "$PROCESS" ]; then
- nvram set button_script_2="0"
- else
- [ -s "/tmp/AiDisk_00/shadowsocks/shadowsocks" ] && nvram set button_script_2="1"
- fi
- ;;
- esac
- rm -f /tmp/button_script.lock
自定义脚本0功能详细配置:adbyby、ShadowSocks、DDNS、迅雷等功能详细设置
- #!/bin/sh
- #copyright by hiboy
- [ -f /tmp/script0.lock ] && exit 0
- touch /tmp/script0.lock
- #↓↓↓功能详细设置(应用设置重启后生效,不能断电重启,要点击右上角重启按钮)↓↓↓
- #多次检测断线后自动重启功能 reb_0关闭;reb_1启动
- touch /tmp/reb_0.lock
- # adbyby 功能 0关闭;1启动
- adbybys=0
- adbybyfile='http://code.taobao.org/svn/padavanrt-n56uopt/7620v151210.tgz'
- adbybyfile2='http://update.adbyby.com/download/7620n.tar.gz'
- #CPU占用率较高时自动关闭adbyby 功能 0关闭;1启动 (其他进程占用过高也会关闭adbyby)
- CPUAverages=0
- # 加载第三方adblock规则【不建议启用第三方规则】 0关闭;1启动(可选项:删除前面的#可生效)
- adblocks=0
- cat > "/tmp/rule_DOMAIN.txt" <<-\EOF
- # 【可选多项,会占用内存:删除前面的#可生效】
- # 【ckaiuang个人收集】ADP规则分享[2015.8.16重新整理和验证规则说明和地址]
- # [综合型]【1】—EasyList China[cjx82630]
- # https://easylist-downloads.adblockplus.org/easylistchina.txt
- # 规则说明:EasyList China主要包含原ChinaList(2014.3.25止约2900条规则)、原cjxlist(对前者的补充,2014.3.21止约2500条规则)。
- # [综合型]【2】—EasyList Lite[cjx82630]
- # https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt
- # 规则说明:EasyList Lite是EasyList的精简,即只收录在中文网站能用到的EasyList规则。约300多K,适合较少访问外国网站的用户。占用内存少。
- # [补充型]【3】—CJX's Annoyance List[cjx82630]
- # https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt
- # 规则说明:过滤烦人的自我推广,并作为EasyPrivacy的补充。
- # [隐私保护型]【4】—EasyPrivacy
- # https://easylist-downloads.adblockplus.org/easyprivacy.txt
- # 规则说明:EasyPrivacy是附属于EasyList的补充型订阅规则。用于尽可能阻止网站及广告商在内的第三方用户跟踪脚本,以减少用户浏览历史被记录,从而保护您的个人资料。这些脚本一般被用于网站精确广告投放的数据统计。因此,只要不过滤用户跟踪脚本,广告商就知道你详细的浏览记录。这些广告商包括百度,google,51,CNZZ等。
- # [综合型]【5】—TW过滤规则[xwhyc]
- # http://bbs.theworld.cn/attachment.php?aid=MTE0NDQ4fDUyZjc3Mjc3fDEzOTc5MTM1OTh8NDczMHBuYytiNk1yR0dQa2lqdGFyOXg1R29QNEVaUjJoYTNIb0U4bXFHeVM0eGM%3D
- # 规则说明:本规则为完全独立规则,非其他规则辅助规则,以简洁、效率为主,建议只安装本规则
- # [补充型]【6】—Simple List
- # https://raw.githubusercontent.com/JixunMoe/SimpleList/master/build/SimpleList.txt
- # 规则说明:对ChinaList的一些查漏补缺。
- # [组合型]【7】—Fanboy Ultimate List[Fanboy旗舰]
- # https://secure.fanboy.co.nz/r/fanboy-ultimate.txt
- # [备用]https://www.fanboy.co.nz/r/fanboy-ultimate.txt
- # 规则说明:该规则包含Easylist、Easyprivacy、Enhanced Trackers List和Annoyances List。
- # 1、EasyList是主要的订阅规则,清除网页广告以及不必要的框架、图像和对象;
- # 2、EasyPrivacy是附属于EasyList的补充型订阅规则。用于尽可能阻止网站及广告商在内的第三方用户跟踪脚本,以减少用户浏览历史被记录,从而保护您的个人资料。这些脚本一般被用于网站精确广告投放的数据统计。因此,只要不过滤用户跟踪脚本,广告商就知道你详细的浏览记录。这些广告商包括百度,google,51,CNZZ等;
- # 3、Enhanced Trackers List用于过滤用户跟踪脚本的过滤,可能是EasyPrivacy的补充;
- # 4、Fanboy-Annoyances List能删除网上的烦恼,从而大大减少网页加载时间;
- # 5、Fanboy Social List移除社交媒体的反馈数据;
- # 6、Fanboy Complete List包含Easylist、Easyprivacy和Enhanced Trackers List。
- # http://code.taobao.org/svn/padavanrt-n56uopt/userh.txt
- EOF
- # 添加过滤白名单地址 0关闭;1启动 (可选项:删除前面的#可生效)
- whitelist=0
- whitehost=qq.com,bilibili.com,acfun.tv
- # opt 自动更新(替换覆盖opt文件夹) 0关闭;1启动
- upopt=0
- #【1;安装到U盘(installs=1)】请设置:
- # ①删除U盘根目录"opt"文件夹(自动安装时会自动创建)
- # ②USB 应用程序 - 其它设置 - 允许运行Optware?选择"Entware"
- #
- #【2;安装到内存(installs=2),需要空余内存:10M】请设置:
- # ①没有百度云、迅雷
- # ②USB 应用程序 - 其它设置 - 允许运行Optware?选择"否"
- installs=1
- ssfile='http://code.taobao.org/svn/padavanrt-n56uopt/optupanv.tgz'
- ssfile2='http://code.taobao.org/svn/padavanrt-n56uopt/opttmpv.tgz'
- # 轻量级隧道代理shadowsocks 功能【0关闭】;【1智能代理,请选择方案】;【2全部走代理】
- ssproxys=0
- #【gfwlists=1;方案一SS+pdnsd+chinadns,国外站点走代理】
- #【gfwlists=2;方案二SS+pdnsd+gfwlist(推荐),只有被墙的站点才走代理】
- gfwlists=2
- # 部署Pcap_DNSProxy (替换ChinaDNS、pdnsd) 0关闭;1启动
- DNSProxy=0
- # udprelay(UDP代理)SS+ss_tunnel(请确认服务器是否支持UDP转发) 0关闭;1启动
- udprelay=0
- # shadowsocks 服务器配置
- server_ip=100.100.100.100
- server_port=1024
- server_password=Hello123World
- server_method=aes-256-cfb
- # 加密方式按需选择,table,rc4,rc4-md5,aes-128-cfb, aes-192-cfb, aes-256-cfb, bf-cfb, camellia-128-cfb, camellia-192-cfb, camellia-256-cfb, cast5-cfb, des-cfb
- local_port=1080
- cat > "/tmp/gfwlist_DOMAIN.txt" <<-\EOF
- # 方案二SS的gfwlist添加例子
- server=/.tvb.com/208.67.222.222#443
- ipset=/.tvb.com/gfw_black_list
- server=/.steampowered.com/208.67.222.222#443
- ipset=/.steampowered.com/gfw_black_list
- server=/.github.io/208.67.222.222#443
- ipset=/.github.io/gfw_black_list
- EOF
- # syncy 功能 0关闭;1启动(需要插入U盘安装opt)
- syncys=0
- #SyncY配置文件路径(写字板打开修改):\\192.168.1.1\Media\AiDisk_a1\opt\etc\syncy
- #配置说明:http://www.syncy.cn/index.php/syncyconfighelp/"
- #可以多个同步目录,直接复制一个config syncpath配置节,然后修改相应的localpath、remotepath等就可以了
- #默认模式:upload+
- #同步模式类型:upload,upload+,download,download+,sync
- # 迅雷远程下载 功能(需要插入U盘安装opt)【0关闭】;【1启动】说明看系统日志
- xunleis=0
- # 迅雷快鸟 功能【0关闭】;
- #【FastDicks=1插U盘启动】
- #【FastDicks=2免U盘启动】
- #【2免U盘启动】需要填写在下方的【迅雷快鸟脚本】,生成脚本两种方法:
- # ①插入U盘,配置自定义脚本【1插U盘启动】启动快鸟一次即可自动生成
- # ②打开https://github.com/fffonion/Xunlei-FastDick,按照网页的说明在PC上运行脚本,登陆成功后会生成swjsq_wget.sh,把swjsq_wget.sh的内容粘贴此处即可
- # 生成后需要到【系统管理】 - 【恢复/导出/上传设置】 - 【路由器内部存储 (/etc/storage)】【提交】保存脚本
- FastDicks=0
- uid="账号"
- pwd="密码"
- # DDNS(删除#/tmp/sh_ddns.sh前面的#即可启动命令)
- #/tmp/sh_ddns.sh /tmp/orayddns.log 'http://您的花生壳帐号:您的帐号密码@ddns.oray.com/ph/update?&hostname=你的ddns域名' &
- #/tmp/sh_ddns.sh /tmp/3322ddns.log 'http://DDNS用户名:DDNS密码@members.3322.org/dyndns/update?hostname=你的ddns域名' &
- #/tmp/sh_ddns.sh /tmp/oyeddns.log 'http://www.gwa2011.com/nsupdate.php?ddns_name=昵称&ddns_password=密码' &
- ###注册地址http://www.gwa2011.com/
- # 花生壳内网版【0关闭】;【1启动】需要插入U盘安装opt
- phddns=0
- #↑↑↑功能详细设置↑↑↑
- echo "" > /var/log/shadowsocks_watchdog.log
- echo "" > /var/log/Pcap_DNSProxy_watchdog.log
- echo "" > /var/log/chinadns_watchdog.log
- upopt()
- {
- rm -f /tmp/optv.txt
- wget -O "/tmp/optv.txt" "http://code.taobao.org/svn/padavanrt-n56uopt/optv.txt"
- if [ $(cat /tmp/optv.txt) != $(cat /opt/optv.txt) ] && [ -f /tmp/optv.txt ]; then
- if [ "$upopt" != "0" ] ; then
- logger -t "【opt】" "opt需要更新,自动启动更新"
- rm -f /opt/optv.txt
- else
- logger -t "【opt】" "opt需要更新,请启动自动更新或手动更新"
- fi
- else
- logger -t "【opt】" "opt不需更新"
- fi
- }
- logger -t "自定义脚本0" "脚本完成"
- rm -f /tmp/script0.lock
自定义脚本1
- #!/bin/sh
- #copyright by hiboy
- [ -f /tmp/script1.lock ] && exit 0
- touch /tmp/script1.lock
- . /etc/storage/script0_script.sh
- http_username=`nvram get http_username`
- export PATH=/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin:/usr/sbin:/usr/bin:/sbin:/bin
- export LD_LIBRARY_PATH=/opt/lib:/lib
- /tmp/sh_dnsmasqs.sh 0
- sed -Ei '/taobao.org/d' /etc/storage/dnsmasq/dnsmasq.servers
- echo 'server=/taobao.org/223.5.5.5' >> /etc/storage/dnsmasq/dnsmasq.servers
- restart_dhcpd
- /etc/storage/inet_state_script.sh 20
- baidu='http://passport.baidu.com/passApi/img/small_blank.gif'
- /tmp/sh_download.sh /tmp/small_blank.gif $baidu
- rb=1
- while [ ! -s /tmp/small_blank.gif ];
- do
- logger -t "自定义脚本1" "等待联网后开始脚本"
- sleep 20
- /tmp/sh_download.sh /tmp/small_blank.gif $baidu
- rb=`expr $rb + 1`
- if [ "$rb" -gt 3 ] ; then
- logger -t "自定义脚本1" "等待联网超时"
- exit
- fi
- done
- rm -f /tmp/small_blank.gif
- cat > "/tmp/sh_downloads_adblock.sh" <<-EOF
- #!/bin/sh
- adblocks=$adblocks
- lazy="http://update.adbyby.com/rule3/lazy.txt"
- video="http://update.adbyby.com/rule3/video.txt"
- rm -f /tmp/data/lazy.txt
- rm -f /tmp/data/video.txt
- rm -f /tmp/data/lazy.bin
- rm -f /tmp/data/video.bin
- rm -f /tmp/data/user.bin
- rm -f /tmp/data/user.txt
- sed -e '/.*update.adbyby.com/d' -i /etc/storage/dnsmasq/hosts
- restart_dhcpd
- sleep 5
- /tmp/sh_download.sh /tmp/data/lazy.txt \$lazy
- /tmp/sh_download.sh /tmp/data/video.txt \$video
- #echo '127.0.0.1 update.adbyby.com' >> /etc/storage/dnsmasq/hosts
- restart_dhcpd
- if [ "\$adblocks" != "0" ] ; then
- mkdir -p /tmp/data
- logger -t "adbyby" "下载adblock规则"
- while read line
- do
- c_line=\`echo \$line |grep -v "#"\`
- if [ ! -z "\$c_line" ] ; then
- rm -f /tmp/data/user2.txt
- logger -t "adbyby" "下载规则:\$line"
- /tmp/sh_download.sh /tmp/data/user2.txt \$line
- grep -v '^!' /tmp/data/user2.txt | grep -E '^(@@\\||\\||[[:alnum:]])' | sort -u >> /tmp/data/user.txt
- rm -f /tmp/data/user2.txt
- fi
- done < /tmp/rule_DOMAIN.txt
- fi
- grep -v '^!' /etc/storage/adbyby_rules_script.sh >> /tmp/data/user.txt
- EOF
- chmod 777 "/tmp/sh_downloads_adblock.sh"
- cat > "/tmp/sh_white_list.sh" <<-EOF
- #!/bin/sh
- whitelist=$whitelist
- if [ "\$whitelist" != "0" ] ; then
- logger -t "adbyby" "添加过滤白名单地址"
- logger -t "adbyby" "加白地址:$whitehost"
- echo whitehost=$whitehost >> /tmp/adhook.ini
- fi
- EOF
- chmod 777 "/tmp/sh_white_list.sh"
- cat > "/tmp/sh_func_load_adbyby.sh" <<-EOF
- #!/bin/sh
- adbybys=$adbybys
- adbybyfile=$adbybyfile
- adbybyfile2=$adbybyfile2
- adblocks=$adblocks
- CPUAverages=$CPUAverages
- if [ "\$adbybys" != "0" ] && [ ! -f /tmp/cron_adb.lock ]; then
- touch /tmp/cron_adb.lock
- killall sh_mon.sh
- killall sh_CPUAverage.sh
- /tmp/sh_adb8118.sh D
- killall -15 adbyby
- killall -9 adbyby
- if [ ! -s "/tmp/adbyby" ] ;then
- rm -f /tmp/adbyby
- logger -t "adbyby" "开始下载7620n.tar.gz"
- /tmp/sh_download.sh /tmp/7620n.tar.gz \$adbybyfile \$adbybyfile2
- /tmp/sh_untar.sh /tmp/7620n.tar.gz /tmp /tmp/adbyby
- fi
- if [ -s "/tmp/adbyby" ] ;then
- chmod 777 /tmp/adbyby
- /tmp/sh_downloads_adblock.sh
- /tmp/sh_white_list.sh
- /tmp/adbyby > /tmp/adbyby.log&
- sleep 3
- /tmp/adbyby > /tmp/adbyby.log&
- #/tmp/adbyby --no-daemon &
- sleep 3
- killall -15 adbyby
- killall -9 adbyby
- sleep 3
- /tmp/adbyby >/dev/null 2>&1 &
- if [ "\$adblocks" != "0" ] ; then
- logger -t "adbyby" "加载adblock规则,等候60秒"
- sleep 60
- else
- sleep 20
- fi
- fi
- if [ -s "/tmp/adbyby.log" ] ;then
- logger -t "adbyby" "启动完成"
- rm -f /tmp/adbyby.log
- rm -f /tmp/7620n.tar.gz
- rm -f /tmp/cron_adb.lock
- logger -t "adbyby" "lazy更新:\`sed -n '1p' /tmp/data/lazy.txt\`"
- logger -t "adbyby" "video更新:\`sed -n '1p' /tmp/data/video.txt\`"
- /tmp/sh_mon.sh&
- if [ "\$CPUAverages" != "0" ] ; then
- /tmp/sh_CPUAverage.sh&
- fi
- fi
- fi
- EOF
- chmod 777 "/tmp/sh_func_load_adbyby.sh"
- sleep 5
- rm -f /tmp/cron_adb.lock
- /tmp/sh_func_load_adbyby.sh
- if [ ! -s "/tmp/adbyby" ] ;then
- rm -f /tmp/7620n.tar.gz
- logger -t "adbyby" "功能关闭"
- fi
- upanPath=`ls -l /media/ | awk '/^d/ {print $NF}' | sed -n '1p'`
- optw_enable=`nvram get optw_enable`
- if [ "$syncys" != "0" ] || [ "$FastDicks" = "1" ] || [ "$ssproxys" != "0" ] || [ "$phddns" != "0" ] && [ "$installs" = "1" ] ; then
- logger -t "opt" "optU盘安装,模式:$installs"
- if [ "$optw_enable" = "2" ] ; then
- SSPath="/media/$upanPath/opt"
- if [ ! -x "$SSPath" ]; then
- mkdir -p /media/$upanPath/opt
- mount -o bind /media/$upanPath/opt /opt
- fi
- ln -sf /media/$upanPath /tmp/AiDisk_00
- upopt
- /tmp/sh_installs.sh $ssfile
- else
- logger -t "opt" "U盘安装失败,需要开启Entware运行环境,请插入U盘,按要求设置"
- syncys=0
- xunleis=0
- logger -t "opt" "U盘安装失败,自动转换内存安装"
- [ "$installs" = "1" ] && installs=2
- [ "$FastDicks" = "1" ] && FastDicks=2
- fi
- fi
- if [ "$ssproxys" != "0" ] || [ "$phddns" != "0" ] && [ "$installs" = "2" ] ; then
- logger -t "opt" "opt内存安装,模式:$installs,没有百度云、迅雷"
- if [ "$optw_enable" = "0" ] ; then
- mkdir -p /tmp/AiDisk_00/opt
- mount -o bind /tmp/AiDisk_00/opt /opt
- upopt
- /tmp/sh_installs.sh $ssfile2
- rm -f /opt/opt.tgz
- rm -fR /opt/shadowsocks
- syncys=0
- xunleis=0
- URLDNSP="http://code.taobao.org/svn/padavanrt-n56uopt/Pcap_DNSProxy-0.4.4.5-statically_mipsel/opt/bin/Pcap_DNSProxy"
- [ "$DNSProxy" != "0" ] && /tmp/sh_download.sh "/opt/bin/Pcap_DNSProxy" $URLDNSP
- else
- logger -t "SS" "内存安装失败,需要关闭Entware运行环境,请按要求设置"
- syncys=0
- xunleis=0
- phddns=0
- ssproxys=0
- installs=0
- fi
- fi
- shadowsockssh="/tmp/AiDisk_00/shadowsocks/shadowsocks"
- err="请更新opt文件夹、检查U盘文件和Entware设置"
- if [ ! -s "/tmp/AiDisk_00/shadowsocks/shadowsocks" ] ;then
- ssproxys=0
- logger -t "SS" "opt缺少shadowsocks文件,$err"
- fi
- if [ "$ssproxys" != "0" ] ; then
- logger -t "SS" "生成服务器配置文件"
- logger -t "SS" "server_ip:$server_ip"
- if [ ! -z /opt/bin/resolveip ]; then
- server_ip=`/opt/bin/resolveip $server_ip | grep -v : | sed -n '1p'`
- logger -t "SS" "resolveip:$server_ip"
- fi
- cat > "/opt/etc/shadowsocks.json" <<-EOF
- {
- "server":"$server_ip",
- "server_port":$server_port,
- "local_address":"0.0.0.0",
- "local_port":$local_port,
- "password":"$server_password",
- "timeout":60,
- "method":"$server_method"
- }
- EOF
- echo $udprelay > /tmp/udprelay.lock
- echo $DNSProxy > /tmp/DNSProxy.lock
- if [ "$ssproxys" = "1" ] ; then
- if [ "$gfwlists" = "1" ] ; then
- logger -t "SS" "$ssproxys【1;方案一】"
- echo "1" > /tmp/SSProxy.lock
- $shadowsockssh set_up
- else
- logger -t "SS" "$ssproxys【2;方案二】"
- echo "2" > /tmp/SSProxy.lock
- $shadowsockssh set_up
- fi
- fi
- if [ "$ssproxys" = "2" ] ; then
- logger -t "SS" "$ssproxys【全部走代理】"
- echo "3" > /tmp/SSProxy.lock
- $shadowsockssh set_up
- fi
- /tmp/sh_ssmon.sh $gfwlists&
- fi
- if [ "$ssproxys" = "0" ] ; then
- logger -t "SS" "关闭,自动删除dnsmasqs配置"
- echo "0" > /tmp/SSProxy.lock
- /tmp/sh_dnsmasqs.sh 0 && restart_dhcpd && rm -f /var/log/shadowsocks.lock
- $shadowsockssh stop && sleep 2
- fi
- if [ "$syncys" != "0" ] ; then
- if [ ! -s "/opt/etc/syncy.py" ] ;then
- logger -t "syncy" "opt缺少syncy.py文件,$err"
- else
- logger -t "syncy" "启动syncy服务"
- sed -i 's/\r//g' /opt/etc/syncy
- python /opt/etc/syncy.py &
- sleep 25
- /tmp/sh_syncyquota.sh&
- fi
- fi
- if [ "$xunleis" != "0" ] ; then
- echo "1" > /tmp/xunleis.lock
- /tmp/sh_xun_lei.sh $xunleis /media/$upanPath/xunlei &
- fi
- if [ "$FastDicks" != "0" ] ; then
- echo "1" > /tmp/FastDicks.lock
- /tmp/sh_FastDick.sh $FastDicks $uid $pwd &
- fi
- if [ "$phddns" != "0" ] ; then
- if [ ! -s "/opt/phddns2/oraynewph.sh" ] ;then
- logger -t "花生壳内网版" "opt缺少oraynewph.sh文件,$err"
- else
- if [ "$installs" = "2" ] ; then
- ln -sf "/etc/storage/PhMain.ini" "/etc/PhMain.ini"
- ln -sf "/etc/storage/init.status" "/etc/init.status"
- wphddns2="http://code.taobao.org/svn/padavanrt-n56uopt/phddns2/bin"
- /tmp/sh_download.sh "/opt/phddns2/bin/oraynewph" "$wphddns2/oraynewph"
- /tmp/sh_download.sh "/opt/phddns2/bin/oraysl" "$wphddns2/oraysl"
- logger -t "花生壳内网版" "现在是免U盘运行,请绑定账号后【提交】内部存储保存配置"
- else
- ln -sf "/etc/storage/PhMain.ini" "/etc/PhMain.ini"
- ln -sf "/etc/storage/init.status" "/etc/init.status"
- fi
- /opt/phddns2/oraynewph.sh start &
- sleep 28
- /opt/phddns2/oraynewph.sh status &
- /tmp/sh_orayd.sh &
- sleep 5
- fi
- fi
- logger -t "自定义脚本1" "脚本完成"
- /etc/storage/crontabs_script.sh &
- upopt
- rm -f /tmp/script1.lock
自定义脚本2
- #!/bin/sh
- #copyright by hiboy
- [ -f /tmp/script2.lock ] && exit 0
- touch /tmp/script2.lock
- cat > "/tmp/sh_download.sh" <<-\EOF
- #!/bin/sh
- output=$1
- url1=$2
- url2=$3
- [ -z "$url2" ] && url2=$url1
- rm -f $output
- wget -O $output $url1 --continue
- if [ ! -s "$output" ] ;then
- logger -t "sh_download" "下载失败:【$output】 URL:【$url1】"
- logger -t "sh_download" "重新下载:【$output】 URL:【$url2】"
- rm -f $output
- sleep 16
- wget -O $output $url2 --continue
- fi
- if [ ! -s "$output" ] ;then
- logger -t "sh_download" "下载失败:【$output】 URL:【$url2】"
- exit 1
- else
- chmod 777 $output
- fi
- EOF
- chmod 777 "/tmp/sh_download.sh"
- cat > "/tmp/sh_untar.sh" <<-\EOF
- #!/bin/sh
- flie=$1
- output=$2
- outputflie=$3
- tar -xzvf $flie -C $output
- if [ ! -s "$outputflie" ] ;then
- logger -t "sh_untar" "解压不正常:$1"
- exit 1
- fi
- EOF
- chmod 777 "/tmp/sh_untar.sh"
- cat > "/tmp/sh_ddns.sh" <<-\EOF
- #!/bin/sh
- flie=$1
- url=$2
- logger -t "ddns" "更新IP地址-$flie"
- while [ "1" ];
- do
- wget -O $flie $url --continue
- sleep 666
- continue
- done
- EOF
- chmod 777 "/tmp/sh_ddns.sh"
- cat > "/tmp/sh_adb8118.sh" <<-\EOF
- #!/bin/sh
- adb=$1
- if [ "$adb" = "D" ] ; then
- iptables -t nat -D PREROUTING -p tcp --dport 80 -j ad_byby
- logger -t "iptables" "删除8118转发规则"
- #echo '127.0.0.1 update.adbyby.com' >> /etc/storage/dnsmasq/hosts
- iptables -t nat -D ad_byby -p tcp --dport 80 -j REDIRECT --to-ports 8118
- iptables -t nat -F ad_byby &> /dev/null
- iptables -t nat -X ad_byby &> /dev/null
- ipset destroy ad_byby &> /dev/null
- iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8118
- else
- logger -t "iptables" "添加8118转发规则"
- sed -e '/.*update.adbyby.com/d' -i /etc/storage/dnsmasq/hosts
- iptables -t nat -N ad_byby
- iptables -t nat -A ad_byby -d `nvram get lan_ipaddr` -j RETURN
- iptables -t nat -A ad_byby -p tcp --dport 80 -j REDIRECT --to-ports 8118
- iptables -t nat -A PREROUTING -p tcp --dport 80 -j ad_byby
- fi
- /etc/storage/ez_buttons_script.sh 3 &
- restart_dhcpd
- EOF
- chmod 777 "/tmp/sh_adb8118.sh"
- cat > "/tmp/sh_mon.sh" <<-\EOF
- #!/bin/sh
- logger -t "adbyby" "adbyby 进程守护启动"
- rm -f /tmp/cron_adb.lock
- reb=1
- while [ "1" ];
- do
- if [ -s "/tmp/adbyby" ] ;then
- if [ ! -f /tmp/cron_adb.lock ]; then
- if [ "$reb" -gt 5 ] && [ ! -f /tmp/reb_0.lock ] ; then
- LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
- echo '['$LOGTIME'] 网络连接中断['$reb'],reboot.' >> /opt/log.txt 2>&1
- sleep 5
- reboot
- fi
- #wget --spider --quiet --timeout=6 www.baidu.com
- #if [ "$?" == "0" ]; then
- baidu='http://passport.baidu.com/passApi/img/small_blank.gif'
- /tmp/sh_download.sh /tmp/small_blank.gif $baidu
- if [ ! -s /tmp/small_blank.gif ]; then
- restart_dhcpd
- sleep 30
- /tmp/sh_download.sh /tmp/small_blank.gif $baidu
- fi
- if [ -s /tmp/small_blank.gif ]; then
- reb=1
- PIDS=$(ps | grep "/tmp/adbyby" | grep -v "grep" | wc -l)
- if [ "$PIDS" = 0 ]; then
- logger -t "adbyby" "网络连接正常"
- logger -t "adbyby" "找不到进程,重启adbyby"
- /tmp/sh_adb8118.sh D
- killall -15 adbyby
- killall -9 adbyby
- sleep 3
- /tmp/adbyby >/dev/null 2>&1 &
- sleep 20
- reb=`expr $reb + 1`
- continue
- fi
- if [ "$PIDS" -gt 2 ]; then
- logger -t "adbyby" "进程重复,重启adbyby"
- /tmp/sh_adb8118.sh D
- killall -15 adbyby
- killall -9 adbyby
- sleep 3
- /tmp/adbyby >/dev/null 2>&1 &
- sleep 20
- continue
- fi
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- if [ "$port" = 0 ]; then
- logger -t "adbyby" "找不到8118转发规则,重新添加"
- /tmp/sh_adb8118.sh A
- fi
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- if [ "$port" -gt 1 ]; then
- logger -t "adbyby" "有多个8118转发规则,删除多余"
- while [[ "$port" != 1 ]]
- do
- /tmp/sh_adb8118.sh D
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- done
- fi
- sleep 66
- else
- logger -t "adbyby" "网络连接中断$reb,关闭adbyby"
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- while [[ "$port" != 0 ]]
- do
- /tmp/sh_adb8118.sh D
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- done
- PIDS=$(ps | grep "adbyby" | grep -v "grep" | wc -l)
- if [ "$PIDS" != 0 ]; then
- killall -15 adbyby
- killall -9 adbyby
- fi
- reb=`expr $reb + 1`
- fi
- fi
- fi
- /etc/storage/ez_buttons_script.sh 3 &
- sleep 65
- continue
- done
- EOF
- chmod 777 "/tmp/sh_mon.sh"
- cat > "/tmp/sh_CPUAverage.sh" <<-\EOF
- #!/bin/sh
- logger -t "adbyby" "路由器负载监控启动"
- while [ "1" ];
- do
- if [ ! -f /tmp/cron_adb.lock ]; then
- CPULoad=`uptime |sed -e 's/\ *//g' -e 's/.*://g' -e 's/,.*//g' -e 's/\..*//g'`
- if [ $((CPULoad)) -ge "2" ];then
- logger -t "adbyby" "CPU负载拥堵,关闭adbyby"
- /tmp/sh_adb8118.sh D
- killall -15 adbyby
- killall -9 adbyby
- touch /tmp/cron_adb.lock
- while [[ "$CPULoad" -ge "2" ]]
- do
- sleep 64
- CPULoad=`uptime |sed -e 's/\ *//g' -e 's/.*://g' -e 's/,.*//g' -e 's/\..*//g'`
- done
- logger -t "adbyby" "CPU负载正常"
- rm -f /tmp/cron_adb.lock
- fi
- fi
- sleep 63
- done
- EOF
- chmod 777 "/tmp/sh_CPUAverage.sh"
- cat > "/tmp/sh_installs.sh" <<-\EOF
- #!/bin/sh
- ssfile=$1
- [ ! -f "/tmp/AiDisk_00/shadowsocks/shadowsocks" ] && cp -fR /opt/shadowsocks /tmp/AiDisk_00 && chmod 777 /tmp/AiDisk_00/shadowsocks -R
- if [ ! -f "/tmp/AiDisk_00/shadowsocks/shadowsocks" ] || [ ! -f "/opt/optv.txt" ] ;then
- logger -t "SS" "自动安装(覆盖opt文件夹)"
- #rm -f /opt/* -R
- logger -t "SS" "opt第一次下载"
- wget -O /opt/opt.tgz $ssfile --continue
- tar -xzvf /opt/opt.tgz -C /opt
- if [ ! -f "/opt/shadowsocks/shadowsocks" ] ;then
- logger -t "SS" "/opt/opt.tgz下载SS失败"
- rm -f /opt/opt.tgz
- logger -t "SS" "opt第二次下载"
- wget -O /opt/opt.tgz $ssfile --continue
- tar -xzvf /opt/opt.tgz -C /opt
- fi
- if [ -s "/opt/shadowsocks/shadowsocks" ] ;then
- logger -t "SS" "opt解压完成"
- chmod 777 /opt -R
- cp -fR /opt/shadowsocks /tmp/AiDisk_00
- chmod 777 /tmp/AiDisk_00/shadowsocks -R
- fi
- fi
- EOF
- chmod 777 "/tmp/sh_installs.sh"
- cat > "/tmp/sh_xun_lei.sh" <<-\EOF
- #!/bin/sh
- export PATH=/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin:/usr/sbin:/usr/bin:/sbin:/bin
- export LD_LIBRARY_PATH=/opt/lib:/lib
- xunleis=$1
- xunleiPath=$2
- xunleifile=$3
- if [ "$xunleis" != "0" ] ; then
- if [ ! -x $xunleiPath ]; then
- mkdir -p $xunleiPath
- fi
- if [ ! -s $xunleiPath"/portal" ] ;then
- logger -t "迅雷下载" "Xware1.0.31_mipsel_32_uclibc"
- Xware1="http://code.taobao.org/svn/padavanrt-n56uopt/Xware1.0.31_mipsel_32_uclibc.tgz"
- /tmp/sh_download.sh "$xunleiPath/Xware1.tgz" $Xware1
- /tmp/sh_untar.sh $xunleiPath"/Xware1.tgz" $xunleiPath "$xunleiPath/portal"
- fi
- if [ ! -s "$xunleiPath/portal" ] ;then
- logger -t "迅雷下载" "xunlei缺少portal文件"
- else
- chmod 777 "$xunleiPath/portal"
- "$xunleiPath/portal"&
- sleep 44
- /tmp/sh_download.sh "/tmp/xunlei.info" "http://`nvram get lan_ipaddr`:9000/getsysinfo" "http://`nvram get lan_ipaddr`:9001/getsysinfo"
- logger -t "迅雷下载" "启动xunlei,绑定设备页面【http://yuancheng.xunlei.com】"
- logger -t "迅雷下载" "在浏览器中输入【http://`nvram get lan_ipaddr`:9000/getsysinfo】"
- logger -t "迅雷下载" "显示错误则输入【http://`nvram get lan_ipaddr`:9001/getsysinfo】"
- logger -t "迅雷下载" "会看到类似如下信息:"
- logger -t "迅雷下载" "`cat /tmp/xunlei.info`"
- logger -t "迅雷下载" "其中有用的几项为:"
- logger -t "迅雷下载" "①:0表示返回结果成功"
- logger -t "迅雷下载" "②:1表示检测网络正常,0表示检测网络异常"
- logger -t "迅雷下载" "④:1表示已绑定成功,0表示未绑定"
- logger -t "迅雷下载" "⑤:未绑定的情况下,为绑定的需要的激活码"
- logger -t "迅雷下载" "⑥:1表示磁盘挂载检测成功,0表示磁盘挂载检测失败"
- /tmp/sh_Thunder.sh &
- fi
- fi
- EOF
- chmod 777 "/tmp/sh_xun_lei.sh"
- cat >/tmp/qos_scheduler.sh <<-\EOF
- #!/bin/sh
- qosc=$1
- echo 0 >/tmp/qos_scheduler.lock
- logger -t "QOS" "终端在线检查启动"
- while [ "1" ];
- do
- if [ "$(cat /tmp/qoss_state)" == "0" ] ; then
- logger -t "QOS" "终端在线检查暂停"
- rm -f /tmp/qos_scheduler.lock
- exit
- fi
- qos_t=`cat /proc/net/arp|fgrep -c 0x2`
- if [ $((qos_t)) -le $qosc ]; then
- if [ $(ifconfig |grep -c imq0) -gt 0 ]; then
- logger -t "QOS" "取消限速,当在线$qos_t台,小于或等于$qosc台"
- ip link set imq0 down
- ip link set imq1 down
- fi
- else
- if [ $(ifconfig |grep -c imq0) -eq 0 ] ; then
- logger -t "QOS" "开始限速,当在线$qos_t台,大于$qosc台"
- ip link set imq0 up
- ip link set imq1 up
- sleep 6
- port=$(iptables -t mangle -L | grep 'IMQ: todev 0' | wc -l)
- if [ "$port" = 0 ]; then
- logger -t "QOS" "找不到QOS规则,重新添加"
- /etc/storage/post_iptables_script.sh&
- fi
- fi
- fi
- sleep 69
- continue
- done
- EOF
- chmod 777 "/tmp/qos_scheduler.sh"
- logger -t "自定义脚本2" "脚本完成"
- rm -f /tmp/script2.lock
自定义脚本3
- #!/bin/sh
- #copyright by hiboy
- [ -f /tmp/script3.lock ] && exit 0
- touch /tmp/script3.lock
- ln -sf "/etc/storage/PhMain.ini" "/etc/PhMain.ini"
- ln -sf "/etc/storage/init.status" "/etc/init.status"
- rm -f "/opt/etc/init.d/S96sh3.sh"
- cat > "/tmp/sh_dnsmasqs.sh" <<-\END
- #!/bin/sh
- gfwlists=$1
- sed -Ei '/no-resolv|server=127.0.0.1|dns-forward-max=1000|min-cache-ttl=1800|shadowsocks\/dnsmasq/d' /etc/storage/dnsmasq/dnsmasq.conf
- if [ "$gfwlists" = "1" ] ; then
- logger -t "SS" "自动写入方案一dnsmasqs配置"
- cat >> "/etc/storage/dnsmasq/dnsmasq.conf" <<-EOF
- no-resolv
- server=127.0.0.1#5353
- dns-forward-max=1000
- min-cache-ttl=1800
- EOF
- fi
- if [ "$gfwlists" = "2" ] ; then
- logger -t "SS" "自动写入方案二dnsmasqs配置"
- cat >> "/etc/storage/dnsmasq/dnsmasq.conf" <<-EOF
- conf-dir=/tmp/AiDisk_00/shadowsocks/dnsmasq.d
- dns-forward-max=1000
- min-cache-ttl=1800
- EOF
- fi
- END
- chmod 777 "/tmp/sh_dnsmasqs.sh"
- cat > "/tmp/sh_ssmon.sh" <<-\EOF
- #!/bin/sh
- gfwlists=$1
- logger -t "SS" "shadowsocks 进程守护启动"
- rebss=1
- rm -f /tmp/cron_ss.lock
- while [ "1" ];
- do
- sleep 67
- /etc/storage/ez_buttons_script.sh 3 &
- if [ ! -f /tmp/cron_ss.lock ] && [ -f "/var/log/shadowsocks.lock" ]; then
- if [ "$rebss" -gt 5 ] && [ ! -f /tmp/reb_0.lock ] ; then
- LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
- logger -t "SS" "['$LOGTIME'] 网络连接shadowsocks中断['$rebss'],reboot."
- sleep 5
- reboot
- fi
- pstmp='ps'
- PROCESS=$($pstmp | grep "ss-redir" | grep -v "grep")
- if [ -z "$PROCESS" ] && [ -f "/var/log/shadowsocks.lock" ]; then
- /opt/etc/init.d/S22shadowsocks restart
- logger -t "SS" "找不到shadowsocks进程$rebss,重启shadowsocks"
- rebss=`expr $rebss + 1`
- fi
- PROCESS=$($pstmp | grep "chinadns" | grep -v "grep")
- if [ -z "$PROCESS" ] && [ -f "/var/log/chinadns.lock" ]; then
- /opt/etc/init.d/S24chinadns restart
- logger -t "SS" "找不到chinadns进程$rebss,重启chinadns"
- rebss=`expr $rebss + 1`
- fi
- PROCESS=$($pstmp | grep "pdnsd" | grep -v "grep")
- if [ -z "$PROCESS" ] && [ -f "/var/log/pdnsd.lock" ]; then
- chmod 755 /etc/pdnsd.conf
- /opt/etc/init.d/S26pdnsd restart
- logger -t "SS" "找不到pdnsd进程$rebss,重启pdnsd"
- fi
- PROCESS=$($pstmp | grep "ss-tunnel" | grep -v "grep")
- if [ -z "$PROCESS" ] && [ -f "/var/log/ss-tunnel.lock" ]; then
- /opt/etc/init.d/S23ss-tunnel restart
- logger -t "SS" "找不到ss-tunnel进程$rebss,重启ss-tunnel"
- fi
- PROCESS=$($pstmp | grep "Pcap_DNSProxy" | grep -v "grep")
- if [ -z "$PROCESS" ] && [ -f "/var/log/pcap_dnsproxy.lock" ]; then
- /opt/etc/init.d/S26pdnsd stop
- /opt/etc/init.d/S24chinadns stop
- /opt/etc/init.d/S27pcap-dnsproxy restart
- logger -t "SS" "找不到Pcap_DNSProxy进程$rebss,重启Pcap_DNSProxy"
- fi
- #wget --spider --quiet --timeout=10 www.google.co.jp
- #if [ "$?" == "0" ]; then
- google='http://www.google.com/images/icons/product/videos-32.png'
- /tmp/sh_download.sh /tmp/videos-32.png $google
- if [ ! -s /tmp/videos-32.png ]; then
- restart_dhcpd
- sleep 30
- /tmp/sh_download.sh /tmp/videos-32.png $google
- fi
- if [ -s /tmp/videos-32.png ]; then
- rm -f /tmp/videos-32.png
- rebss=1
- #logger -t "SS" "网络连接shadowsocks正常"
- sleep 68
- else
- logger -t "SS" "网络连接shadowsocks中断$rebss,重启shadowsocks$gfwlists"
- rebss=`expr $rebss + 1`
- /tmp/AiDisk_00/shadowsocks/shadowsocks set_up
- fi
- fi
- continue
- done
- EOF
- chmod 777 "/tmp/sh_ssmon.sh"
- cat > "/tmp/sh_syncyquota.sh" <<-\EOF
- #!/bin/sh
- logger -t "syncy" "等待SyncY同步软件启动,SyncY同步软件技术博客:http://www.syncy.cn/"
- while [ ! -s "/tmp/syncy.quota" ]
- do
- sleep 11
- if [ -s "/tmp/syncy.user_code" ] ;then
- user_code_log=`cat /tmp/syncy.user_code`
- logger -t "syncy" "$user_code_log"
- logger -t "syncy" "打开百度授权页面https://openapi.baidu.com/device"
- logger -t "syncy" "输入用户码【$user_code_log】(请在100秒内输入用户码)"
- while [ ! -s "/tmp/syncy.user_token" ]
- do
- sleep 12
- if [ -s "/tmp/syncy.user_token" ] ;then
- user_code_log=`cat /tmp/syncy.user_token`
- logger -t "syncy" "$user_code_log"
- logger -t "syncy" "显示【Get device token success.】表示授权完成。"
- /tmp/sh_syncyd.sh &
- fi
- done
- fi
- done
- user_code_log=`cat /tmp/syncy.quota`
- logger -t "syncy" "$user_code_log"
- logger -t "syncy" "SyncY同步启动成功"
- logger -t "syncy" "SyncY同步软件技术博客:http://www.syncy.cn/"
- EOF
- chmod 777 "/tmp/sh_syncyquota.sh"
- cat > "/tmp/sh_syncyd.sh" <<-\EOF
- #!/bin/sh
- logger -t "syncy" "SyncY守护进程启动"
- pid_file="/var/run/syncy.pid"
- start_cmd="/opt/etc/syncy.py &"
- while true; do
- running=$(ps | grep "/opt/etc/syncy.py" | grep -v "grep" | wc -l)
- if [ $running -le 0 ]; then
- eval $start_cmd
- echo "start syncy"
- logger -t "syncy" "SyncY重新启动"
- else
- echo "syncy is running"
- fi
- sleep 65
- done
- EOF
- chmod 777 "/tmp/sh_syncyd.sh"
- cat > "/tmp/sh_orayd.sh" <<-\EOF
- #!/bin/sh
- logger -t "花生壳内网版" "守护进程启动"
- online=""
- onlinetest()
- {
- orayslstatus=`head -n 3 /tmp/oraysl.status`
- online=$(echo $orayslstatus | grep "ONLINE" | wc -l)
- }
- onlinetest
- while [ $online -le 0 ]; do
- sleep 68
- onlinetest
- logger -t "花生壳内网版" "$online"
- done
- logger -t "花生壳内网版" "ONLINE"
- while true; do
- sleep 68
- onlinetest
- running=$(ps | grep "/opt/usr/oray-app/bin/oraynewph" | grep -v "grep" | wc -l)
- running2=$(ps | grep "/opt/usr/oray-app/bin/oraysl" | grep -v "grep" | wc -l)
- if [ $running -le 0 ] || [ $running2 -le 0 ] || [ $online -le 0 ]; then
- /opt/phddns2/oraynewph.sh reset &
- logger -t "花生壳内网版" "重新启动"
- else
- echo "oray is running"
- fi
- done
- EOF
- chmod 777 "/tmp/sh_orayd.sh"
- cat > "/tmp/sh_Thunder.sh" <<-\EOF
- #!/bin/sh
- upanPath=`ls -l /media/ | awk '/^d/ {print $NF}' | sed -n '1p'`
- logger -t "迅雷下载" "守护进程启动$upanPath"
- while true; do
- running=$(ps | grep "/xunlei/lib/" | grep -v "grep" | wc -l)
- if [ $running -le 2 ] ; then
- /media/$upanPath/xunlei/portal &
- logger -t "迅雷下载" "重新启动"
- else
- echo "xunlei is running"
- fi
- sleep 71
- done
- EOF
- chmod 777 "/tmp/sh_Thunder.sh"
- cat > "/tmp/sh_FastDick.sh" <<-\EOF
- #!/bin/sh
- #copyright by hiboy
- export PATH=/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin:/usr/sbin:/usr/bin:/sbin:/bin
- export LD_LIBRARY_PATH=/opt/lib:/lib
- FastDicks=$1
- uid=$2
- pwd=$3
- if [ "$FastDicks" != "0" ] ; then
- logger -t "迅雷快鸟" "迅雷快鸟(diǎo)路由器版:https://github.com/fffonion/Xunlei-FastDick"
- if [ "$FastDicks" = "2" ] ; then
- logger -t "迅雷快鸟" "稍等几分钟,ssh到路由,控制台输入【ps】命令查看[/opt/FastDick/swjsq_wget.sh]进程是否存在,是否正常启动,提速是否成功。"
- logger -t "迅雷快鸟" "免U盘启动"
- chmod 777 "/etc/storage/FastDick_script.sh"
- /etc/storage/FastDick_script.sh &
- else
- rm -f "/opt/FastDick/" -R
- mkdir -p "/opt/FastDick"
- swjsqfile="https://raw.githubusercontent.com/fffonion/Xunlei-FastDick/master/swjsq.py"
- /tmp/sh_download.sh "/opt/FastDick/swjsq.py" $swjsqfile
- chmod 777 "/opt/FastDick/swjsq.py"
- logger -t "迅雷快鸟" "程序下载完成,正在启动 python /opt/FastDick/swjsq.py"
- echo "$uid,$pwd" >/opt/FastDick/swjsq.account.txt
- chmod 777 /opt/FastDick -R
- cd /opt/FastDick
- python /opt/FastDick/swjsq.py 2>&1 > /opt/FastDick/swjsq.log &
- chmod 777 "/opt/FastDick" -R
- sleep 30
- chmod 777 "/opt/FastDick" -R
- if [ -f /opt/FastDick/swjsq_wget.sh ]; then
- logger -t "迅雷快鸟" "自动备份swjsq文件到路由,【提交内部存储】后下次重启可以免U盘启动了"
- cat > "/etc/storage/FastDick_script.sh" <<-\EEF
- #!/bin/sh
- # 迅雷快鸟【2免U盘启动】功能需到【自定义脚本0】配置【FastDicks=2】,并在此输入swjsq_wget.sh文件内容
- #【2免U盘启动】需要填写在下方的【迅雷快鸟脚本】,生成脚本两种方法:
- # ①插入U盘,配置自定义脚本【1插U盘启动】启动快鸟一次即可自动生成
- # ②打开https://github.com/fffonion/Xunlei-FastDick,按照网页的说明在PC上运行脚本,登陆成功后会生成swjsq_wget.sh,把swjsq_wget.sh的内容粘贴此处即可
- # 生成后需要到【系统管理】 - 【恢复/导出/上传设置】 - 【路由器内部存储 (/etc/storage)】【提交】保存脚本
- EEF
- cat /opt/FastDick/swjsq_wget.sh >> /etc/storage/FastDick_script.sh
- chmod 777 "/etc/storage/FastDick_script.sh"
- fi
- logger -t "迅雷快鸟" "启动完成`cat /opt/FastDick/swjsq.log`"
- fi
- else
- rm -f "/opt/FastDick/" -R
- fi
- EOF
- chmod 777 "/tmp/sh_FastDick.sh"
- logger -t "自定义脚本3" "脚本完成"
- rm -f /tmp/script3.lock
迅雷快鸟脚本:(把swjsq_wget.sh的内容粘贴此处)
- #!/bin/sh
- # 迅雷快鸟【2免U盘启动】功能需到【自定义脚本0】配置【FastDicks=2】,并在此输入swjsq_wget.sh文件内容
- #【2免U盘启动】需要填写在下方的【迅雷快鸟脚本】,生成脚本两种方法:
- # ①插入U盘,配置自定义脚本【1插U盘启动】启动快鸟一次即可自动生成
- # ②打开https://github.com/fffonion/Xunlei-FastDick,按照网页的说明在PC上运行脚本,登陆成功后会生成swjsq_wget.sh,把swjsq_wget.sh的内容粘贴此处即可
- # 生成后需要到【系统管理】 - 【恢复/导出/上传设置】 - 【路由器内部存储 (/etc/storage)】【提交】保存脚本
adbyby 自定义过滤规则
- ! ------------------------------ ADByby 自定义过滤语法简--------------------------------
- ! -------------- 规则基于abp规则,并进行了字符替换部分的扩展-----------------------------
- ! ABP规则请参考 https://adblockplus.org/zh_CN/filters ,下面为大致摘要
- ! "!" 为行注释符,注释行以该符号起始作为一行注释语义,用于规则描述。
- ! "*" 为字符通配符,能够匹配0长度或任意长度的字符串,该通配符不能与正则语法混用。
- ! "^" 为分隔符,可以是除了字母、数字或者 _ - . % 之外的任何字符。
- ! "|" 为管线符号,来表示地址的最前端或最末端
- ! "||" 为子域通配符,方便匹配主域名下的所有子域。
- ! "~" 为排除标识符,通配符能过滤大多数广告,但同时存在误杀, 可以通过排除标识符修正误杀链接。
- ! "##" 为元素选择器标识符,后面跟需要隐藏元素的CSS样式例如 #ad_id .ad_class
- !! 元素隐藏暂不支持全局规则和排除规则
- !! 字符替换扩展
- ! 文本替换选择器标识符,后面跟需要替换的文本数据,格式:$s@模式字符串@替换后的文本@
- ! 支持通配符*和?
自定义Crontab定时任务配置
- #!/bin/sh
- #copyright by hiboy
- [ -f /tmp/crontabs.lock ] && exit 0
- touch /tmp/crontabs.lock
- http_username=`nvram get http_username`
- upanPath=`ls -l /media/ | awk '/^d/ {print $NF}' | sed -n '1p'`
- cat > "/etc/storage/cron/crontabs/$http_username" <<-EOF
- # 基本格式 :
- # * * * * * command
- # 分 时 日 月 周 命令
- # 在以上各个字段中,还可以使用以下特殊字符:
- # 星号(*):代表所有可能的值,例如month字段如果是星号,则表示在满足其它字段的制约条件后每月都执行该命令操作。
- # 逗号(,):可以用逗号隔开的值指定一个列表范围,例如,“1,2,5,7,8,9”
- # 中杠(-):可以用整数之间的中杠表示一个整数范围,例如“2-6”表示“2,3,4,5,6”
- # 正斜线(/):可以用正斜线指定时间的间隔频率,例如“0-23/2”表示每两小时执行一次。同时正斜线可以和星号一起使用,例如*/10,如果用在minute字段,表示每十分钟执行一次。
- #
- # 定时运行脚本规则 (删除前面的#即可启动命令)
- # 每5小时重启adbyby
- 0 */5 * * * /tmp/sh_func_load_adbyby.sh &
- # 每天的一点25分更新中国路由表
- 25 1 * * * /tmp/AiDisk_00/shadowsocks/shadowsocks update_chnroutes &
- # 每天的一点20分更新gfw表
- 20 1 * * * /tmp/AiDisk_00/shadowsocks/shadowsocks update_gfwlist &
- # 每天的三点半重启
- #30 3 * * * reboot &
- # 每星期一的三点半重启
- #30 3 * * 1 reboot &
- # 凌晨2点定时关网:
- #0 2 * * * stop_wan
- # 早上8点定时开网(重启wan口):
- #0 8 * * * restart_wan
- # 每天的一点【切换WAN模式】和【重启wan口】
- #0 1 * * * /tmp/sh_wan_wips.sh wan &
- # 每天的十点切换wifi中继模式
- #0 10 * * * /tmp/sh_wan_wips.sh wips &
- # 每6小时重启迅雷快鸟
- 15 */6 * * * /tmp/sh_reFastDick.sh &
- # 每3小时重启迅雷下载
- 5 */3 * * * killall EmbedThunderManager &
- # 每1小时重启花生壳内网版
- 10 */1 * * * killall oraynewph && killall oraysl &
- EOF
- chmod 777 "/etc/storage/cron/crontabs/$http_username"
- cat > "/tmp/sh_wan_wips.sh" <<-\EOF
- #!/bin/sh
- logger -t "WAN、WIFI中继开关" "切换模式:$1"
- restartwan()
- {
- logger -t "WAN、WIFI中继开关" "重新链接wan口"
- restart_wan
- sleep 10
- logger -t "WAN、WIFI中继开关" "重新启动2.4GWIFI"
- radio2_restart
- }
- case "$1" in
- wan)
- #无线AP工作模式:"0"=【AP(桥接被禁用)】"1"=【WDS桥接(AP被禁用)】"2"=【WDS中继(网桥 + AP)】"3"=【AP-Client(AP被禁用)】"4"=【AP-Client + AP】
- nvram set rt_mode_x=0
- nvram commit
- restartwan
- ;;
- wips)
- #无线AP工作模式:"0"=【AP(桥接被禁用)】"1"=【WDS桥接(AP被禁用)】"2"=【WDS中继(网桥 + AP)】"3"=【AP-Client(AP被禁用)】"4"=【AP-Client + AP】
- nvram set rt_mode_x=4
- nvram commit
- restartwan
- ;;
- esac
- EOF
- chmod 777 "/tmp/sh_wan_wips.sh"
- cat > "/tmp/sh_reFastDick.sh" <<-\EOF
- #!/bin/sh
- if [ -f "/tmp/FastDicks.lock" ]; then
- logger -t "迅雷快鸟" "重新启动中……"
- killall FastDick_script.sh
- killall swjsq.py
- killall python /opt/FastDick/swjsq.py
- killall /opt/FastDick/swjsq.py
- logger -t "迅雷快鸟" "已经关闭,十五分钟后启动"
- sleep 900
- logger -t "迅雷快鸟" "启动/etc/storage/FastDick_script.sh"
- /etc/storage/FastDick_script.sh &
- fi
- EOF
- chmod 777 "/tmp/sh_reFastDick.sh"
- /etc/storage/ez_buttons_script.sh 3 &
- killall crond
- crond
- if [ ! -f /tmp/cron_adb.lock ] && [ -s "/tmp/adbyby" ]; then
- PIDS=$(ps | grep "/tmp/adbyby" | grep -v "grep" | wc -l)
- if [ "$PIDS" != 0 ]; then
- port=$(iptables -t nat -L | grep 'ports 8118' | wc -l)
- if [ "$port" = 0 ]; then
- logger -t "adbyby" "找不到8118转发规则,重新添加"
- /tmp/sh_adb8118.sh A
- fi
- fi
- fi
- rm -f /tmp/crontabs.lock
版权声明:
作者:hopol
链接:https://www.hopolcn.com/2015/12/369/
来源:HopoL's Blog
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论