#! /bin/sh | |
# load_iptables.sh | |
# | |
# Script that uses build_iptables.pl to create a ruleset from files for the | |
# next two days then load it with iptables-restore. | |
# Copyright (c) 2009 Terry Burton | |
# | |
# http://www.terryburton.co.uk | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | |
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | |
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | |
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
# IN THE SOFTWARE. | |
PATH='/usr/bin:/bin:/usr/sbin:/sbin' | |
NUM_DAYS=2 | |
BUILD_IPTABLES=`dirname $0`/build_iptables.pl | |
DOMAINS_DIR=/srv/domains | |
DATES=`seq -f "%.0f day" 0 $((NUM_DAYS-1)) | date -f - +"$DOMAINS_DIR/%Y%m%d.txt" | tr "\n" " "` | |
RULES_FILE=`mktemp /tmp/load_iptables.XXXXXXXX` | |
$BUILD_IPTABLES $DATES > $RULES_FILE | |
iptables -F | |
iptables -X | |
iptables-restore $RULES_FILE | |
rm -f $RULES_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment