summaryrefslogtreecommitdiff
path: root/TLD/generate.sh
blob: 9ccace7c235480cff597484218fb9c66e27f85bf (plain)
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
#!/bin/bash
BASE=$(dirname "$0")
TEMPLATE=tld_template.js
if [ -f "$1" ]; then
  cp "$1" "$BASE/$TEMPLATE"
fi
pushd "$BASE" >/dev/null
fname=public_suffix_list.dat
nflag=""
if [ -f "$fname" ]; then
  nflag="-z $fname"
  cp "$fname" "$fname.bak"
fi
echo 'Updating TLDs...'
URL=https://publicsuffix.org/list/$fname
curl -sO $nflag "$URL"

if ! grep 'com' "$fname" >/dev/null; then
  echo >&2 "$fname empty or corrupt!"
  exit 1
fi

./generate.pl
[ -f "$fname.bak" ] && diff "$fname" "$fname.bak" && echo 'No new data from pubblic suffix list.'
popd >/dev/null