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 %s" "$GEN_CONFIG"
87 filtergen "$CONFIG" `basename $filter` > "$GEN_CONFIG"
97 nls "%s not generated" "$GEN_CONFIG"
100 nls "%s outdated" "$GEN_CONFIG"
103 nls "%s not applied" "$GEN_CONFIG"
106 nls "filter rules applied"
111 msg_usage "$0 {start|stop|init|restart|reload|status}"