Initial import

This commit is contained in:
2017-02-21 02:35:57 +01:00
commit d06a79e353
16 changed files with 2117 additions and 0 deletions

59
update_ipv4_adress_space.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/sh
update_url="http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.txt"
base_dnscache_dir=/opt/dnscache
dnscache_ip_dir=${base_dnscache_dir}/root/ip
if [ ! -d $base_dnscache_dir -o ! -d $dnscache_ip_dir ]; then
echo
echo "[ ERROR ]: Installtion directory for dnscache not found"
echo " exiting now.."
echo
exit 1
fi
tmp_file="/tmp/ipv4_addresss_space.$$.lst"
wget $update_url -O $tmp_file > /dev/null 2>&1
if [ $? -gt 0 ];then
echo
echo "[ ERROR ]: cannot fetch $update_url "
echo " exiting now.."
echo
rm -f $tmp_file
exit 2
fi
adress_spaces=`grep -e " \(ALLOCATED\)$\|\(LEGACY\)$" $tmp_file | awk '{print$1}' | cut -d "/" -f 1 | sed -e's/^0*\(.*\)$/\1/'`
if [ -z "$adress_spaces" ] ; then
echo
echo "[ ERROR ]: No adress space data found $update_url "
echo " exiting now.."
echo
rm -f $tmp_file
exit 3
fi
## - delete old entries..
## -
rm -rf $dnscache_ip_dir/*
cd $dnscache_ip_dir
for i in $adress_spaces; do
touch ${i}
done
## - send the servive a HUP signal
## -
svc -h $base_dnscache_dir
rm -f $tmp_file
exit 0