2018-06-30 17:01:23 -06:00
|
|
|
#!/bin/bash
|
2021-06-18 16:21:23 -06:00
|
|
|
|
|
|
|
# Copyright (C) 2005-2021 Giorgio Maone <https://maone.net>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2018-06-30 17:01:23 -06:00
|
|
|
BASE=$(dirname "$0")
|
2018-09-05 05:33:38 -06:00
|
|
|
TEMPLATE=tld_template.js
|
2018-08-17 20:14:55 -06:00
|
|
|
if [ -f "$1" ]; then
|
2018-09-05 05:33:38 -06:00
|
|
|
cp "$1" "$BASE/$TEMPLATE"
|
2018-08-17 20:14:55 -06:00
|
|
|
fi
|
2018-09-05 05:33:38 -06:00
|
|
|
pushd "$BASE" >/dev/null
|
2018-06-30 17:01:23 -06:00
|
|
|
fname=public_suffix_list.dat
|
|
|
|
nflag=""
|
2018-08-01 17:50:09 -06:00
|
|
|
if [ -f "$fname" ]; then
|
2018-06-30 17:01:23 -06:00
|
|
|
nflag="-z $fname"
|
2018-09-05 05:33:38 -06:00
|
|
|
cp "$fname" "$fname.bak"
|
2018-06-30 17:01:23 -06:00
|
|
|
fi
|
2018-09-05 05:33:38 -06:00
|
|
|
echo 'Updating TLDs...'
|
2018-06-30 17:01:23 -06:00
|
|
|
URL=https://publicsuffix.org/list/$fname
|
2018-09-05 05:33:38 -06:00
|
|
|
curl -sO $nflag "$URL"
|
2018-06-30 17:01:23 -06:00
|
|
|
|
2018-08-01 17:50:09 -06:00
|
|
|
if ! grep 'com' "$fname" >/dev/null; then
|
2018-06-30 17:01:23 -06:00
|
|
|
echo >&2 "$fname empty or corrupt!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
./generate.pl
|
2018-09-05 05:33:38 -06:00
|
|
|
[ -f "$fname.bak" ] && diff "$fname" "$fname.bak" && echo 'No new data from pubblic suffix list.'
|
|
|
|
popd >/dev/null
|