packages/net/ddns-scripts/tools/public_suffix_list.sh
Christian Schoenebeck 728f37ad15 [for-15.05] ddns-scripts: backport of 2.7.6-10
Backport of current version 2.7.6-10
- more services
- more functionality
- be prepared for next versions

compiled ipk-packages available at
https://github.com/chris5560/OpenWrt-Backports/tree/master/for-CC15.05.01/ddns-scripts_2.7.6-10

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2017-01-11 17:05:05 +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