From 7d54341e1d221a90f195820d8c5bcddcea79513e Mon Sep 17 00:00:00 2001 From: lonord Date: Sat, 31 Jul 2021 12:46:09 +0800 Subject: [PATCH] optimize code --- .travis.yml | 14 +++++++------- Makefile | 2 +- root/etc/init.d/ss-domain-rule | 10 ++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 409ae72..89e06d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,8 @@ env: global: - PACKAGE=luci-app-ss-domain-rule - DOWNLOAD_DIR=${HOME}/files - - SDK_PATH=https://downloads.openwrt.org/releases/18.06.8/targets/x86/64 - - SDK=-sdk-18.06.8-x86-64_ + - SDK_PATH=https://downloads.openwrt.org/releases/18.06.7/targets/x86/64 + - SDK=-sdk-18.06.7-x86-64_ - CONFIG_CCACHE=y install: - mkdir -p "$HOME/files" && cd "$HOME/files" @@ -46,11 +46,11 @@ install: - test -d "feeds" && rm -rf feeds || true - ln -s "$HOME/dl" dl - ln -s "$HOME/feeds" feeds - - echo "src-git base https://github.com/openwrt/openwrt.git" >feeds.conf - - echo "src-git packages https://github.com/openwrt/packages.git" >>feeds.conf - - echo "src-git luci https://github.com/openwrt/luci.git" >>feeds.conf - - echo "src-git routing https://git.openwrt.org/feed/routing.git" >>feeds.conf - - echo "src-git telephony https://github.com/openwrt/telephony.git" >>feeds.conf + - echo "src-git base https://github.com/openwrt/openwrt.git;v18.06.7" >feeds.conf + - echo "src-git packages https://github.com/openwrt/packages.git^925068d4f8366240d2aeb2d69b3df12382320ec3" >>feeds.conf + - echo "src-git luci https://github.com/openwrt/luci.git^41e2258d6dc1ebe8d3874ae6d6b13db49cff2c5c" >>feeds.conf + - echo "src-git routing https://git.openwrt.org/feed/routing.git^0e63ef9276bf41c0d4176127f9f047343b8ffe32" >>feeds.conf + - echo "src-git telephony https://github.com/openwrt/telephony.git^8ecbdabc7c5cadbe571eb947f5cd333a5a785010" >>feeds.conf - ln -s "$TRAVIS_BUILD_DIR" "package/$PACKAGE" script: - cd "$SDK_HOME" diff --git a/Makefile b/Makefile index dddde78..3b7c082 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ss-domain-rule -PKG_VERSION:=1.0.4 +PKG_VERSION:=1.0.5 PKG_RELEASE:=1 PKG_LICENSE:=GPLv3 diff --git a/root/etc/init.d/ss-domain-rule b/root/etc/init.d/ss-domain-rule index 020c7a5..35656d5 100755 --- a/root/etc/init.d/ss-domain-rule +++ b/root/etc/init.d/ss-domain-rule @@ -21,6 +21,7 @@ DNSMASQ_RULE=$DNSMASQ_CONF_DIR/ss-domain-rule.conf DATA_DIR=/etc/ss-domain-rule GFWLIST_CACHE=$DATA_DIR/gfwlist_domain.txt +GFWLIST_CACHE_TMP=/tmp/gfwlist_domain.txt.tmp GFWLIST_TIMESTAMP=$DATA_DIR/update_time.txt GFWLIST_FETCH_ADDR=https://cokebar.github.io/gfwlist2dnsmasq/gfwlist_domain.txt @@ -138,8 +139,13 @@ unset_cron() { download_gfwlist() { # echo "DEBUG - download_gfwlist start" test -d $DATA_DIR || mkdir -p $DATA_DIR - wget -q --timeout=15 -O $GFWLIST_CACHE $GFWLIST_FETCH_ADDR 2>&1 | $LOG_ERR - echo "$(date)" > $GFWLIST_TIMESTAMP + wget -q --timeout=15 -O $GFWLIST_CACHE_TMP $GFWLIST_FETCH_ADDR 2>&1 | $LOG_ERR + if [ $? -eq 0 -a -n "$(head $GFWLIST_CACHE_TMP)" ]; then + mv $GFWLIST_CACHE_TMP $GFWLIST_CACHE + echo "$(date)" > $GFWLIST_TIMESTAMP + else + echo "gfwlist update failed" + fi # echo "DEBUG - download_gfwlist end" }