-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunboundblock.sh
More file actions
38 lines (29 loc) · 810 Bytes
/
Copy pathunboundblock.sh
File metadata and controls
38 lines (29 loc) · 810 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
URL="https://dbl.oisd.nl"
TMPFILE=$(mktemp) || exit 1
BLOCKL="blockhost.conf"
UBOUND="/var/unbound"
DATE=$(date '+%Y%m%d')
OS=$(uname -s)
trap 'rm -f $TMPFILE' INT HUP TERM
echo "====[script start: $(date)]===="
[ -f $BLOCKL ] && \
mv $BLOCKL $BLOCKL.$DATE
if [ "$OS" == "OpenBSD" ]; then
# use "-S noverifytime" in case of certain errors. man 1 ftp
ftp -o $TMPFILE $URL
else
wget -c --passive -O $TMPFILE $URL
fi
sed -e '/^#/d' -e '/^$/d' \
-e 's/\(.*\)/local-zone: "\1" always_nxdomain/' \
$TMPFILE > $TMPFILE.TMP \
&& mv $TMPFILE.TMP $BLOCKL \
&& rm -f $TMPFILE
# move the file to unbound's etc directory
if [ "$OS" == "OpenBSD" ]; then
mv $BLOCKL $UBOUND/etc/
fi
# cleanup, since the new blocklist generated successfully
rm -f $BLOCKL.$DATE
echo "====[script end: $(date)]===="