noscript/TLD/generate.sh

31 lines
666 B
Bash
Raw Normal View History

#!/bin/bash
2021-06-18 16:21:23 -06:00
2023-02-22 15:17:12 -07:00
# Copyright (C) 2005-2023 Giorgio Maone <https://maone.net>
2021-06-18 16:21:23 -06:00
#
# SPDX-License-Identifier: GPL-3.0-or-later
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