2 # ipchains/iptables rules generator
5 # description: ipchains/iptables rules generator
7 # Source function library
8 . /etc/rc.d/init.d/functions
11 . /etc/sysconfig/network
14 CONFIG=/etc/filter/simple.conf
15 GEN_CONFIG=/etc/filter/generated_rules
16 SUBSYS=/var/lock/subsys/filter
17 [ -f /etc/sysconfig/filter ] && . /etc/sysconfig/filter
19 # Check that networking is up.
20 # if is_no "${NETWORKING}" ; then
21 # msg_network_down "filter"
26 if [ ! -e $GEN_CONFIG ]; then
28 elif [ $GEN_CONFIG -ot $CONFIG ]; then
30 elif [ $SUBSYS -ot $GEN_CONFIG ]; then
38 iptables=`which iptables 2> /dev/null`
39 ipchains=`which ipchains 2> /dev/null`
40 if [ -n "$iptables" ]; then
42 elif [ -n "$ipchains" ]; then
45 nls "ipchains/iptables not found. cannot continue"
51 # See how we were called.
55 if [ $confstatus -ge 0 ]; then
56 if [ $confstatus -gt 0 ]; then
59 show "Setting filter rules"
63 if [ $RETVAL = 0 ]; then
72 show "Flushing filter rules"
76 if [ $RETVAL = 0 ]; then
84 show "Generating $GEN_CONFIG"
87 filtergen $CONFIG `basename $filter` > $GEN_CONFIG
97 nls "$GEN_CONFIG not generated"
100 nls "$GEN_CONFIG outdated"
103 nls "$GEN_CONFIG not applied"
106 nls "filter rules applied"
111 msg_Usage "$0 {start|stop|restart|init|status}"