diff options
Diffstat (limited to 'config/ipblocklist/convert-execute.sh')
-rw-r--r--[-rwxr-xr-x] | config/ipblocklist/convert-execute.sh | 81 |
1 files changed, 49 insertions, 32 deletions
diff --git a/config/ipblocklist/convert-execute.sh b/config/ipblocklist/convert-execute.sh index 916cd1b5..0dddc42f 100755..100644 --- a/config/ipblocklist/convert-execute.sh +++ b/config/ipblocklist/convert-execute.sh @@ -1,42 +1,55 @@ #!/bin/sh -#Version 2.2 logging + +#check if ipblocklist running +#export resultr=`pfctl -s rules | grep -c ipblocklist` + +#echo $resultr +#if [ "$resultr" -gt "0" ]; then +# echo running +# exit 1 +#else +# echo not running +# /usr/bin/logger -s "IP-Blocklist was found not running" +# echo "IP-Blocklist not running" | /usr/local/bin/php /usr/local/www/packages/ipblocklist/email_send.php +#fi + #kill tables to elminate dups -pfctl -t ipblocklist -T kill -pfctl -t ipblocklistW -T kill -sed -i -e '/ipblocklist/d' /tmp/rules.debug -sed -i -e '/ipblocklistW/d' /tmp/rules.debug +/sbin/pfctl -t ipblocklist -T kill +/sbin/pfctl -t ipblocklistW -T kill +/usr/bin/sed -i -e '/ipblocklist/d' /tmp/rules.debug +/usr/bin/sed -i -e '/ipblocklistW/d' /tmp/rules.debug #Generate lists to process -ls lists > file_list.txt -ls Wlists > file_Wlist.txt -filelist="file_list.txt" -Wfilelist="file_Wlist.txt" +ls /usr/local/www/packages/ipblocklist/lists > /usr/local/www/packages/ipblocklist/file_list.txt +ls /usr/local/www/packages/ipblocklist/Wlists > /usr/local/www/packages/ipblocklist/file_Wlist.txt +filelist="/usr/local/www/packages/ipblocklist/file_list.txt" +Wfilelist="/usr/local/www/packages/ipblocklist/file_Wlist.txt" #READ contents in file_list.txt and process as file for fileline in $(cat $filelist); do -iplist="lists/$fileline" -iplistout="lists/ipfw.ipfw" -perl convert.pl $iplist $iplistout +iplist="/usr/local/www/packages/ipblocklist/lists/$fileline" +iplistout="/usr/local/www/packages/ipblocklist/lists/ipfw.ipfw" +/usr/bin/perl convert.pl $iplist $iplistout done #Whitelist for Wfileline in $(cat $Wfilelist); do -Wiplist="Wlists/$Wfileline" -Wiplistout="Wlists/whitelist" -perl convert.pl $Wiplist $Wiplistout +Wiplist="/usr/local/www/packages/ipblocklist/Wlists/$Wfileline" +Wiplistout="/usr/local/www/packages/ipblocklist/Wlists/whitelist" +/usr/bin/perl convert.pl $Wiplist $Wiplistout done #echo "ipfw made" #clean up ipfw.ipfw (duplicates) -rm lists/ipfw.ipfwTEMP -sort lists/ipfw.ipfw | uniq -u >> lists/ipfw.ipfwTEMP -mv lists/ipfw.ipfwTEMP lists/ipfw.ipfw +rm /usr/local/www/packages/ipblocklist/lists/ipfw.ipfwTEMP +/usr/bin/sort lists/ipfw.ipfw | uniq -u >> /usr/local/www/packages/ipblocklist/lists/ipfw.ipfwTEMP +mv /usr/local/www/packages/ipblocklist/lists/ipfw.ipfwTEMP /usr/local/www/packages/ipblocklist/lists/ipfw.ipfw #echo "ipfw clean" #clean up whitelist (duplicates) rm Wlists/whitelistTEMP -sort Wlists/whitelist | uniq -u >> Wlists/whitelistTEMP +/usr/bin/sort Wlists/whitelist | uniq -u >> Wlists/whitelistTEMP mv Wlists/whitelistTEMP Wlists/whitelist #echo "whitelist clean" @@ -56,7 +69,7 @@ t=$(($t+'1')) rm /tmp/rules.debug.tmp #Insert table-entry limit -sed -i -e '/900000/d' /tmp/rules.debug +/usr/bin/sed -i -e '/900000/d' /tmp/rules.debug while read line do a=$(($a+1)); #echo $a; @@ -70,7 +83,7 @@ done < "/tmp/rules.debug" mv /tmp/rules.debug /tmp/rules.debug.old mv /tmp/rules.debug.tmp /tmp/rules.debug -pfctl -o basic -f /tmp/rules.debug > errorOUT.txt 2>&1 +/sbin/pfctl -o basic -f /tmp/rules.debug > /usr/local/www/packages/ipblocklist/errorOUT.txt 2>&1 rm /tmp/rules.debug.tmp #Insert ipblocklist rules @@ -84,15 +97,19 @@ while read line echo "#ipblocklist" >> /tmp/rules.debug.tmp echo "table <ipblocklist> persist file '/usr/local/www/packages/ipblocklist/lists/ipfw.ipfw'" >> /tmp/rules.debug.tmp echo "table <ipblocklistW> persist file '/usr/local/www/packages/ipblocklist/Wlists/whitelist'" >> /tmp/rules.debug.tmp - echo "pass quick from <ipblocklistW> to any label 'IP-Blocklist'" >> /tmp/rules.debug.tmp - echo "pass quick from any to <ipblocklistW> label 'IP-Blocklist'" >> /tmp/rules.debug.tmp - if [ -f logging ]; then - echo "block log quick from <ipblocklist> to any label 'IP-Blocklist'" >> /tmp/rules.debug.tmp - echo "block log quick from any to <ipblocklist> label 'IP-Blocklist'" >> /tmp/rules.debug.tmp - else - echo "block quick from <ipblocklist> to any label 'IP-Blocklist'" >> /tmp/rules.debug.tmp - echo "block quick from any to <ipblocklist> label 'IP-Blocklist'" >> /tmp/rules.debug.tmp - fi + + for i in $(cat /usr/local/www/packages/ipblocklist/interfaces.txt); do + echo "pass quick from <ipblocklistW> to any label 'IP-Blocklist'" >> /tmp/rules.debug.tmp + echo "pass quick from $i to <ipblocklistW> label 'IP-Blocklist'" >> /tmp/rules.debug.tmp + if [ -f /usr/local/www/packages/ipblocklist/logging ]; then + echo "block log quick from <ipblocklist> to $i label 'IP-Blocklist'" >> /tmp/rules.debug.tmp + else + echo "block quick from <ipblocklist> to $i label 'IP-Blocklist'" >> /tmp/rules.debug.tmp + fi + if [ -f /usr/local/www/packages/ipblocklist/OUTBOUND ]; then + echo "block quick from $i to <ipblocklist> label 'IP-Blocklist'" >> /tmp/rules.debug.tmp + fi + done fi echo $line >> /tmp/rules.debug.tmp done < "/tmp/rules.debug" @@ -102,5 +119,5 @@ mv /tmp/rules.debug.tmp /tmp/rules.debug #Now execute the ipfw list (Take a long time in old version) #sh lists/ipfw.ipfw (Version 0.1.4) -rm errorOUT.txt -pfctl -o basic -f /tmp/rules.debug > errorOUT.txt 2>&1 +rm /usr/local/www/packages/ipblocklist/errorOUT.txt +/sbin/pfctl -o basic -f /tmp/rules.debug > /usr/local/www/packages/ipblocklist/errorOUT.txt 2>&1 |