4 # Sebastien Luttringer <seblu+arch@seblu.net>
5 # Bart De Schuymer <bdschuym@pandora.be>
6 # Rok Papez <rok.papez@arnes.si>
7 # Dag Wieers <dag@wieers.com>
12 #default configuration:
13 EBTABLES_TEXT_FORMAT
="yes"
14 EBTABLES_BINARY_FORMAT
="yes"
15 EBTABLES_MODULES_UNLOAD
="yes"
16 EBTABLES_SAVE_ON_STOP
="no"
17 EBTABLES_SAVE_ON_RESTART
="no"
18 EBTABLES_SAVE_COUNTER
="no"
20 [[ -r "/etc/conf.d/ebtables" ]] && .
"/etc/conf.d/ebtables"
25 stat_busy
"Starting ebtables"
26 ! ck_daemon ebtables
&& stat_done
&& RETVAL
=0 && return
27 if [[ "$EBTABLES_BINARY_FORMAT" = yes ]]; then
28 for table
in $
(ls /etc
/ebtables
/ebtables.
* 2>/dev
/null |
sed -e 's/.*ebtables\.//' -e '/save/d' ); do
29 /usr
/sbin
/ebtables
-t ${table} --atomic-file /etc
/ebtables
/ebtables.
${table} --atomic-commit || RETVAL
=1
31 elif [[ "$EBTABLES_TEXT_FORMAT" = "yes" ]]; then
32 [[ ! -r /etc
/ebtables
/ebtables
]] && :>/etc
/ebtables
/ebtables
33 /usr
/sbin
/ebtables-restore
</etc
/ebtables
/ebtables || RETVAL
=1
38 if (( RETVAL
== 0 )); then
47 stat_busy
"Stopping ebtables"
48 ck_daemon ebtables
&& stat_done
&& RETVAL
=0 && return
49 for table
in $
(grep '^ebtable_' /proc
/modules |
sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
50 /usr
/sbin
/ebtables
-t $table --init-table || RETVAL
=1
53 if [[ "$EBTABLES_MODULES_UNLOAD" = yes ]]; then
54 for mod
in $
(grep -E '^(ebt|ebtable)_' /proc
/modules | cut
-f1 -d' ') ebtables
; do
55 /sbin
/rmmod
$mod 2> /dev
/null
59 if (( RETVAL
== 0 )); then
74 stat_busy
"Saving ebtables"
75 if [[ "$EBTABLES_TEXT_FORMAT" = yes ]]; then
76 if [[ -r /etc
/ebtables
/ebtables
]]; then
77 mv -f /etc
/ebtables
/ebtables
/etc
/ebtables
/ebtables.save
79 /usr
/sbin
/ebtables-save
>/etc
/ebtables
/ebtables || RETVAL
=1
81 if [[ "$EBTABLES_BINARY_FORMAT" = yes ]]; then
82 rm -f /etc
/ebtables
/ebtables.
*.save
83 for oldtable
in $
(ls /etc
/ebtables
/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 :> /etc
/ebtables
/ebtables.
$table
88 /usr
/sbin
/ebtables
-t $table --atomic-file /etc
/ebtables
/ebtables.
$table --atomic-save || RETVAL
=1
89 if [[ "$EBTABLES_SAVE_COUNTER" = no
]]; then
90 /usr
/sbin
/ebtables
-t $table --atomic-file /etc
/ebtables
/ebtables.
$table -Z || RETVAL
=1
95 (( RETVAL
== 0 )) && stat_done || stat_fail
103 [[ "$EBTABLES_SAVE_ON_STOP" = yes ]] && save
107 [[ "$EBTABLES_SAVE_ON_RESTART" = yes ]] && save
111 ! ck_daemon ebtables
&& restart
118 /usr
/sbin
/ebtables-save
122 echo "Usage $0 {start|stop|restart|condrestart|save|status}"
128 # vim:set ts=2 sw=2 ft=sh noet: