-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunbound-2d2-l1s7-ph15h1n9-001.sh
98 lines (78 loc) · 2.9 KB
/
unbound-2d2-l1s7-ph15h1n9-001.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/ksh
####### unbound-2d2-l1s7-ph15h1n9-001.sh
### AUTHOR: seheyah
### CREATION: 2022/08/21
### DATE: 2023/07/24
### UPDATE:
# Change redirect to always_nxdomain
### CONSTANT
# ARRAY
# FILE
filebkp01="your_backup_path/2d2-l1s7-ph15h1n9-001.bkp"
filerun01="/var/unbound/etc/2d2-l1s7-ph15h1n9-001.txt"
filerun02="/var/unbound/etc/unbound.conf"
filetmp01="/tmp/0.txt"
filetmp02="/tmp/1.txt"
filetmp03="/tmp/2.txt"
# STRING
str0x00="unbound-2d2-l1s7-ph15h1n9-001"
str0x01="2d2-l1s7-ph15h1n9-001.txt"
str0x02="2022/08/21"
str0x03="Falken"
str0x04="0xff"
str0x05="https://dl.red.flag.domains/red.flag.domains.txt"
### VARIABLE
# INTEGER
##### MAIN
echo "|-------------------------------------------------------------------------------------------"
echo "| 0-0-0- |-> $str0x00\n|\n|\t Service: UNBOUND\n|\t Action: Update file $str0x01\n|"
echo "|\t Version: $str0x04\n|\t Release date: $str0x03\n|\t Release name: $str0x02"
echo "|-------------------------------------------------------------------------------------------"
### MAIN
## > Download file
ftp -o $filetmp01 $str0x05 > /dev/null
## > Test file and exit the generation of the file
if [ ! -f $filetmp01 ]; then
echo "|\n| 0-0-0- |-> File download: error\n|"
echo "|-------------------------------------------------------------------------------------------"
echo "| exit 0"
echo "|-------------------------------------------------------------------------------------------"
exit 0
else
echo "|\n| 0-0-0- |-> File download: done"
sed -i '1,2d' $filetmp01
cat $filetmp01 | awk '{ print $1 }' > $filetmp02
while read line; do
echo "\tlocal-zone: \"$line.\" always_nxdomain" >> $filetmp03
done < $filetmp02
echo "" >> $filetmp03
a="$(cat $filerun01 | grep "local-zone" | wc -l)"
b="$(cat $filetmp03 | grep "local-zone" | wc -l)"
echo "|\n|\t Total of previous entries:\t$a"
echo "|\t Total of new entries:\t\t$b"
fi
## > Make a backup file of the previous version
mv $filerun01 $filebkp01
mv $filetmp03 $filerun01
## > Check UNBOUND daemon with the new file
unbound-checkconf /var/unbound/etc/unbound.conf > /dev/null 2>&1
ERROR_CODE=$?
if [ $ERROR_CODE != 0 ]; then
echo "|\n| 0-0-0- |-> UNBOUND can NOT be reload with the new file"
mv $filebkp01 $filerun01
rcctl reload unbound > /dev/null
echo "| 0-0-0- |-> UNBOUND reloaded with the previous file\n|"
else
echo "|\n| 0-0-0- |-> UNBOUND can be reload with the new file"
rcctl reload unbound > /dev/null
echo "| 0-0-0- |-> UNBOUND reloaded with the new file\n|"
fi
rm -f $filetmp01
rm -f $filetmp02
echo "|-------------------------------------------------------------------------------------------"
echo "|\n| 0-0-0- |-> Clean workspace: done\n|"
echo "|-------------------------------------------------------------------------------------------"
echo "| exit 0"
echo "|-------------------------------------------------------------------------------------------"
exit 0
####### END