Project

General

Profile

Download (1.42 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
# Update bogons file
4
# Part of the pfSense project
5
# www.pfsense.com
6

    
7
echo "rc.update_bogons.sh is starting up." | logger
8

    
9
# Sleep for that time, unless an argument is specified.
10

    
11
if [ "$1" = "" ]; then
12
    # Grab a random value  
13
    value=`od -A n -d -N2 /dev/random | awk '{ print $1 }'`
14
    echo "rc.update_bogons.sh is sleeping for $value" | logger
15
    sleep $value
16
fi    
17

    
18
echo "rc.update_bogons.sh is beginning the update cycle." | logger
19

    
20
# Mount RW if needed
21
/etc/rc.conf_mount_rw
22

    
23
/usr/bin/fetch -q -o /tmp/bogons "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt"
24
if [ ! -f /tmp/bogons ]; then
25
	echo "Could not download http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt" | logger
26
	# Relaunch and sleep
27
	sh /etc/rc.update_bogons.sh & 
28
	exit
29
fi
30

    
31
BOGON_MD5=`/usr/bin/fetch -q -o - "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5" | awk '{ print $4 }'`
32
ON_DISK_MD5=`md5 /tmp/bogons | awk '{ print $4 }'`
33
if [ "$BOGON_MD5" = "$ON_DISK_MD5" ]; then
34
	egrep -v "^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8" /tmp/bogons > /etc/bogons
35
	/etc/rc.conf_mount_ro
36
	RESULT=`/sbin/pfctl -t bogons -T replace -f /etc/bogons 2>&1`
37
	rm /tmp/bogons
38
	echo "Bogons file downloaded:  $RESULT" | logger
39
else
40
	echo "Could not download http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5 (md5 mismatch)" | logger
41
	# Relaunch and sleep
42
	sh /etc/rc.update_bogons.sh & 	
43
fi
44

    
45
echo "rc.update_bogons.sh is ending the update cycle." | logger
46

    
(91-91/101)