forked from robynhub/kit-censura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcensorship-get
executable file
·55 lines (41 loc) · 1.86 KB
/
censorship-get
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
#!/bin/bash
# This master script runs the scripts which download and parse each
# blacklist.
# It must not fail even if one of the steps fail.
source config.sh
if [ ! -d "$TMP_DIR" ] ; then mkdir "$TMP_DIR" ; fi
if [ ! -d "$LISTS_DIR" ] ; then mkdir "$LISTS_DIR" ; fi
if [ ! -d "$LOG_DIR" ] ; then mkdir "$LOG_DIR" ; fi
test $LOGGING_ENABLE == true && echo "$(date '+%d/%m/%y %H:%M:%S') - ******* New run *******" >> $LOGFILE
test $LOGGING_ENABLE == true && echo "$(date '+%d/%m/%y %H:%M:%S') - Censorship GET started." >> $LOGFILE
if [ "$1" ]; then
LISTS="$1"
fi
# update each list
for list in $LISTS; do
test $LOGGING_ENABLE == true && echo "$(date '+%d/%m/%y %H:%M:%S') - updating list $list" >> $LOGFILE
# download the list and parse it
if ! ./update_$list; then
echo "WARNING: $list.update has failed with rc=$?!" >&2
test $LOGGING_ENABLE == true && echo "$(date '+%d/%m/%y %H:%M:%S') - WARNING: $list.update has failed with rc=$?!" >> $LOGFILE
continue
fi
# second sanity check
if [ ! -e $LISTS_DIR/$list.new ]; then
echo "WARNING: $LISTS_DIR/$list.new has not been created!" >&2
test $LOGGING_ENABLE == true && echo "$(date '+%d/%m/%y %H:%M:%S') - WARNING: $LISTS_DIR/$list.new has not been created!" >> $LOGFILE
continue
fi
mv $LISTS_DIR/$list.new $LISTS_DIR/$list
# The by-IP list is generated only by some sources. The program assumes
# that if the by-name list was generated correctly then this one will
# have been too.
if [ -e $LISTS_DIR/$list-ip.new ]; then
mv $LISTS_DIR/$list-ip.new $LISTS_DIR/$list-ip
fi
done
# If there are any changes, generate (but not upload) a new named.conf file
# from the intermediate parsed files stored in lists/
./build-bind-config "$LISTS"
./build-unbound-config "$LISTS"
test $LOGGING_ENABLE == true && echo "$(date '+%d/%m/%y %H:%M:%S') - Censorship GET ended." >> $LOGFILE