Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bl_incremental
#!/bin/bash -
###########################################################################
# Original by burningpenguin
# Modified by joel clendineng
###########################################################################
rm -rf /root/blacklist/*
printf "\n Get files: custom_block"
cp /root/custom_block.txt /root/blacklist/blacklistcustom_block
cat /root/blacklist/blacklistcustom_block >> /root/blacklist/blacklist
printf "\n Amount of lines in custom_block %s \n" `cat /root/blacklist/blacklistcustom_block | wc -l`
rm -rf /root/blacklist/blacklistcustom_block
printf "\n Amount of lines in the combined blacklist before any cleanup is done %s \n" `cat /root/blacklist/blacklist | wc -l`
printf "\n Sort ip's and make them unique"
cat /root/blacklist/blacklist | sort | uniq > /root/blacklist/blacklisttmp1
printf "\n Remove comments etc."
egrep -v '(^[[:space:]]*/|^[[:space:]]*#|^[[:space:]]*$)|/[0-9]|\:|/g' /root/blacklist/blacklisttmp1 > /root/blacklist/blacklisttmp2
sed 's/\r//g' /root/blacklist/blacklisttmp2 > /root/blacklist/blacklisttmp3
sed -rn '/((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])/p' /root/blacklist/blacklisttmp3 > /root/blacklist/blacklist
printf "\n Amount of lines in blacklisttmp2 %s \n" `cat /root/blacklist/blacklisttmp2 | wc -l`
printf "\n Amount of lines in blacklisttmp3 %s \n" `cat /root/blacklist/blacklisttmp3 | wc -l`
printf "\n Amount of lines in final blacklist %s \n" `cat /root/blacklist/blacklist | wc -l`
rm -rf /etc/shorewall/blacklist
cp /root/blacklist/blacklist /etc/shorewall/blacklist
shorewall update &>/dev/null
shorewall refresh &>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment