3 # init script for the Ethernet Bridge filter tables
5 # Written by Dag Wieers <dag@wieers.com>
6 # Modified by Rok Papez <rok.papez@arnes.si>
7 # Bart De Schuymer <bdschuym@pandora.be>
10 # description: Ethernet Bridge filtering tables
12 # config: __SYSCONFIG__/ebtables (text)
13 # __SYSCONFIG__/ebtables.<table> (binary)
15 source /etc/init.d/functions
16 source /etc/sysconfig/network
18 # Check that networking is up.
19 [ ${NETWORKING} = "no" ] && exit 0
21 [ -x __EXEC_PATH__/ebtables ] || exit 1
22 [ -x __EXEC_PATH__/ebtables-save ] || exit 1
23 [ -x __EXEC_PATH__/ebtables-restore ] || exit 1
27 desc="Ethernet bridge filtering"
30 #default configuration
31 EBTABLES_TEXT_FORMAT="yes"
32 EBTABLES_BINARY_FORMAT="yes"
33 EBTABLES_MODULES_UNLOAD="yes"
34 EBTABLES_SAVE_ON_STOP="no"
35 EBTABLES_SAVE_ON_RESTART="no"
36 EBTABLES_SAVE_COUNTER="no"
38 config=__SYSCONFIG__/$prog-config
39 [ -f "$config" ] && . "$config"
42 echo -n $"Starting $desc ($prog): "
43 if [ "$EBTABLES_BINARY_FORMAT" = "yes" ]; then
44 for table in $(ls __SYSCONFIG__/ebtables.* 2>/dev/null | sed -e 's/.*ebtables\.//' -e '/save/d' ); do
45 __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-commit || RETVAL=1
48 __EXEC_PATH__/ebtables-restore < /etc/sysconfig/ebtables || RETVAL=1
51 if [ $RETVAL -eq 0 ]; then
52 success "$prog startup"
53 rm -f /var/lock/subsys/$prog
55 failure "$prog startup"
61 echo -n $"Stopping $desc ($prog): "
62 for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
63 __EXEC_PATH__/ebtables -t $table --init-table || RETVAL=1
66 if [ "$EBTABLES_MODULES_UNLOAD" = "yes" ]; then
67 for mod in $(grep -E '^(ebt|ebtable)_' /proc/modules | cut -f1 -d' ') ebtables; do
68 rmmod $mod 2> /dev/null
72 if [ $RETVAL -eq 0 ]; then
73 success "$prog shutdown"
74 rm -f /var/lock/subsys/$prog
76 failure "$prog shutdown"
87 echo -n $"Saving $desc ($prog): "
88 if [ "$EBTABLES_TEXT_FORMAT" = "yes" ]; then
89 if [ -e __SYSCONFIG__/ebtables ]; then
90 chmod 0600 __SYSCONFIG__/ebtables
91 mv -f __SYSCONFIG__/ebtables __SYSCONFIG__/ebtables.save
93 __EXEC_PATH__/ebtables-save > __SYSCONFIG__/ebtables || RETVAL=1
95 if [ "$EBTABLES_BINARY_FORMAT" = "yes" ]; then
96 rm -f __SYSCONFIG__/ebtables.*.save
97 for oldtable in $(ls __SYSCONFIG__/ebtables.* 2>/dev/null | grep -vF 'ebtables.save'); do
99 mv -f $oldtable $oldtable.save
101 for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
102 __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-save || RETVAL=1
103 if [ "$EBTABLES_SAVE_COUNTER" = "no" ]; then
104 __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table -Z || RETVAL=1
109 if [ $RETVAL -eq 0 ]; then
110 success "$prog saved"
112 failure "$prog saved"
122 [ "$EBTABLES_SAVE_ON_STOP" = "yes" ] && save
126 [ "$EBTABLES_SAVE_ON_RESTART" = "yes" ] && save
130 [ -e /var/lock/subsys/$prog ] && restart
137 __EXEC_PATH__/ebtables-save
141 echo $"Usage $0 {start|stop|restart|condrestart|save|status}"