packages/net/ddns-scripts/tools/public_suffix_list.sh
Christian Schoenebeck 10e0400a23 ddns-scripts: no longer build public_suffix_list.dat.gz during build
- no longer build public_suffix_list.dat.gz during build #3678
- replace "\s" with "[[:space:]]" inside Makefile because "\s" ignored by some sed versions
- tools/public_suffix_list.sh still available to rebuild public_suffix_list.dat.gz outside OpenWRT/LEDE build system

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2016-12-25 16:02:52 +01:00

39 lines
1 KiB
Bash
Executable file

#!/bin/sh
URL="https://publicsuffix.org/list/public_suffix_list.dat"
TMPFILE=$(dirname $0)/public_suffix_list.tmp
DATFILE=$(dirname $0)/public_suffix_list.dat
wget -O $TMPFILE $URL || exit 1
# there might be backslashes (at line end they produce problems)
sed -i 's/\\//g' $TMPFILE
# clear DATFILE if exist
printf %s "" > $DATFILE
L=0; M=0
export CHARSET=UTF-8 # needed for idn
cat ${TMPFILE} | while read LINE; do
L=$(( L + 1 ))
printf "\\r\\t%s\\t%s" "in: $L " "out: $(( $L + $M )) "
printf %s\\n "$LINE" | grep -E "^\/\/" >/dev/null 2>&1 && {
# do not modify lines beginning with "//"
printf %s\\n "$LINE" >> $DATFILE
continue
}
printf %s\\n "$LINE" | grep -E "^$" >/dev/null 2>&1 && {
# do not modify empty lines
printf %s\\n "$LINE" >> $DATFILE
continue
}
ASCII=$(idn -a "$LINE") # write ASCII and UTF-8
if [ "$ASCII" != "$LINE" ]; then
printf %s\\n "$ASCII" >> $DATFILE
printf "\\t%s\\n" "add: $ASCII"
M=$(( M + 1 ))
fi
printf %s\\n "$LINE" >> $DATFILE
done
rm -f $TMPFILE
gzip -f9 $DATFILE