4 # Copyright (C) 2009 Universita` di Pisa
6 # This script parse the ipfw rules
7 # and remove the old ones.
9 # The ipfw output is parsed and each time
10 # value stored as comment is compared against
12 # If the time value is older than current,
13 # the rules and related pipes will be deleted.
17 DEBUG=0 # 1 to enable debug messages
18 LOG_FILE=/tmp/ipfw.log
19 # variable shared with the vsys ipfw-be backend
22 debug() # $1 debug message
25 echo "$1" >> $LOG_FILE
29 # Get $NOW referred to UTC
32 # check for module existence
33 /sbin/lsmod | grep ipfw >> /dev/null
34 if [ x"$?" == x"1" ]; then
35 debug "ipfw module does not exist"
42 system("echo Start to clean rules >> /tmp/ipfw.log");
53 # call the backend script to cleanup expired rules
54 command="echo delete " type " " port " | /vsys/ipfw-be ";
55 # grep for the username
56 command=command "`grep :" slice_id ": /etc/passwd | cut -d ':' -f 1`";
62 END { system("echo " cleaned " rules cleaned >> /tmp/ipfw.log");