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"
52 # See how we were called.
56 if [ $confstatus -ge 0 ]; then
57 if [ $confstatus -gt 0 ]; then
60 show "Setting filter rules"
63 [ $? -ne 0 ] && RETVAL=1
64 if [ $RETVAL -eq 0 ]; then
73 show "Flushing filter rules"
77 if [ $RETVAL = 0 ]; then
85 show "Generating %s" "$GEN_CONFIG"
88 filtergen "$CONFIG" `basename $filter` > "$GEN_CONFIG"
99 nls "%s not generated" "$GEN_CONFIG"
102 nls "%s outdated" "$GEN_CONFIG"
105 nls "%s not applied" "$GEN_CONFIG"
108 nls "filter rules applied"
111 [ "$confstatus" -ne 0 ] && RETVAL=3
114 msg_usage "$0 {start|stop|init|restart|force-reload|status}"