3 # init script for the Ethernet Bridge filter tables
6 # description: Ethernet Bridge filtering tables
8 # config: /etc/sysconfig/ebtables (text)
9 # /etc/sysconfig/ebtables.<table> (binary)
11 EBTABLES_CONFIG=/etc/sysconfig/ebtables
12 if [ ! -f $EBTABLES_CONFIG ]; then
14 start|restart|force-reload)
21 . /etc/rc.d/init.d/functions
23 #default configuration
24 EBTABLES_TEXT_FORMAT="yes"
25 EBTABLES_BINARY_FORMAT="yes"
26 EBTABLES_SAVE_ON_STOP="no"
27 EBTABLES_SAVE_ON_RESTART="no"
28 EBTABLES_SAVE_COUNTER="no"
29 [ -f /etc/sysconfig/ebtables-config ] && . /etc/sysconfig/ebtables-config
32 # don't do squat if we don't have the config file
33 if [ -f $EBTABLES_CONFIG ]; then
34 show "Starting Ethernet bridge filtering (ebtables)"
35 if is_yes "$EBTABLES_BINARY_FORMAT"; then
36 for table in $(ls /etc/sysconfig/ebtables.* 2>/dev/null | sed -e 's/.*ebtables\.//' -e '/save/d' ); do
37 /usr/sbin/ebtables -t $table --atomic-file /etc/sysconfig/ebtables.$table --atomic-commit || RETVAL=1
40 /usr/sbin/ebtables-restore < /etc/sysconfig/ebtables || RETVAL=1
43 if [ $RETVAL -eq 0 ]; then
45 touch /var/lock/subsys/ebtables
53 show "Stopping Ethernet bridge filtering (ebtables)"
54 for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
55 /usr/sbin/ebtables -t $table --init-table || RETVAL=1
58 if [ $RETVAL -eq 0 ]; then
60 rm -f /var/lock/subsys/ebtables
72 show "Saving Ethernet bridge filtering (ebtables)"
73 if is_yes "$EBTABLES_TEXT_FORMAT"; then
74 if [ -e /etc/sysconfig/ebtables ]; then
75 chmod 0600 /etc/sysconfig/ebtables
76 mv -f /etc/sysconfig/ebtables /etc/sysconfig/ebtables.save
78 /usr/sbin/ebtables-save > /etc/sysconfig/ebtables || RETVAL=1
80 if is_yes "$EBTABLES_BINARY_FORMAT"; then
81 rm -f /etc/sysconfig/ebtables.*.save
82 for oldtable in $(ls /etc/sysconfif/ebtables.* 2>/dev/null | grep -vF 'ebtables.save'); do
84 mv -f $oldtable $oldtable.save
86 for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
87 /usr/sbin/ebtables -t $table --atomic-file /etc/sysconfig/ebtables.$table --atomic-save || RETVAL=1
88 if [ "$EBTABLES_SAVE_COUNTER" = "no" ]; then
89 /usr/sbin/ebtables -t $table --atomic-file /etc/sysconfig/ebtables.$table -Z || RETVAL=1
94 if [ $RETVAL -eq 0 ]; then
106 is_yes "$EBTABLES_SAVE_ON_STOP" && save
110 is_yes "$EBTABLES_SAVE_ON_RESTART" && save
114 [ -e /var/lock/subsys/ebtables ] && restart
121 for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
122 /usr/sbin/ebtables -t $table --list
126 echo $"Usage $0 {start|stop|restart|condrestart|save|status}"