Chinaunix首页 | 论坛 | 博客
  • 博客访问: 782929
  • 博文数量: 81
  • 博客积分: 612
  • 博客等级: 中士
  • 技术积分: 1216
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-03 14:38
个人简介

蝴蝶翅膀的力量,也许能够改变这个世界。

文章分类

全部博文(81)

文章存档

2020年(2)

2019年(2)

2018年(6)

2017年(2)

2016年(5)

2015年(7)

2014年(20)

2013年(12)

2012年(25)

分类: IT业界

2018-09-29 11:04:13

在上篇中,由于**的list是会经常变动的,因此我写了个脚本放在 **list-autoupdate/blob/master/**list_autoupdate.sh 同时将该脚本设置为OpenWRT crontab entry,每天进行一次更新,这样就解决了这个问题。

点击(此处)折叠或打开

  1. #!/bin/sh
  2. # Name: **list_autoupdate.sh
  3. # Desription: A script is executed from a crontab entry every day to update dnsmasq rules.
  4. # Version: 2018.09.29
  5. # Author: chou.o.ning@gmail.com
  6. # Website: **list-autoupdate
  7. # wget output file
  8. FILE1=dnsmasq_**list_ipset_org.conf
  9. FILE2=dnsmasq_**list_ipset_add_by_ning.conf
  10. FILE3=dnsmasq_**list_ipset.conf
  11. # wget log file
  12. LOGFILE=wget.log
  13. # wget download url
  14. URL1=**list2dnsmasq/dnsmasq_**list_ipset.conf
  15. URL2=web/releases/download/latest/dnsmasq_**list_ipset_add_by_ning.conf
  16. wget $URL1 --no-check-certificate -O $FILE1 -o $LOGFILE || exit 1
  17. wget $URL2 --no-check-certificate -O $FILE2 -a $LOGFILE || exit 1
  18. cat $FILE1 $FILE2 > $FILE3
  19. cp $FILE3 /etc/$FILE3
  20. /etc/init.d/dnsmasq restart

这个脚本中会从两个地方获取**list,一个是
**list2dnsmasq/dnsmasq_**list_ipset.conf 由Cokebar Chi维护
web/releases/download/latest/dnsmasq_**list_ipset_add_by_ning.conf 由本人维护
然后拼接起来拷贝到/etc/dnsmasq_**list_ipset.conf,dnsmasq重启服务即可。

注意事项:
1. OpenWRT需要安装wget组件
2. 需要将**list_autoupdate.sh上传到/root目录下(可以安装openssh-sftp-server,使用sftp命令完成上载)
3. 如果原先crontab为空,则OpenWRT的crond是不启动的,需要手动启动root@OpenWrt:~# /etc/init.d/cron start
4. crontab entry添加命令如下:
root@OpenWrt:~# crontab -e
# update **list at 4:30am every day
30 4 * * * sh /root/**list_autoupdate.sh
5. OpenWRT需要设置正确的时区,否则更新的时间会有8个小时的时差,可以用logread看日志crond是否在工作
阅读(1295) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chou_o_ning2018-09-29 15:44:46

所有的gfw都变成了**