From e28703b7b8bf89ec444e7fc49311f14db80b1c89 Mon Sep 17 00:00:00 2001 From: Konstantin Zamyakin Date: Wed, 31 Oct 2018 15:46:02 +0300 Subject: [PATCH] don't download filter rules if file already exists --- postinstall.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/postinstall.sh b/postinstall.sh index 41785b6..bf0e819 100644 --- a/postinstall.sh +++ b/postinstall.sh @@ -13,14 +13,20 @@ case "$1" in --gecos "<%= project %> user" \ --shell /bin/bash "<%= user %>" fi - URL="https://filters.adtidy.org/android/filters/15.txt" + OUTFILE="/var/lib/dnsfilter/dns.txt" - mkdir -p /var/lib/dnsfilter - wget -q --timeout=90 "$URL" -O "$OUTFILE" - if [ $? -ne 0 ] - then - echo "Filter rules could not be downloaded." + if [ ! -f "${OUTFILE}" ]; then + echo "${OUTFILE} does not exists. Downloading..." + + URL="https://filters.adtidy.org/android/filters/15.txt" + + mkdir -p /var/lib/dnsfilter + wget -q --timeout=90 "$URL" -O "$OUTFILE" + if [ $? -ne 0 ] + then + echo "Filter rules could not be downloaded." + fi fi ;; *)