Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / ebtables / ebtables.sysv
blobb6848f14257e8a87f09d009a7def4ddf1c935612
1 #!/bin/bash
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>
9 # chkconfig: - 15 85
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
25 RETVAL=0
26 prog="ebtables"
27 desc="Ethernet bridge filtering"
28 umask 0077
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"
41 start() {
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
46 done
47 else
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
54 else
55 failure "$prog startup"
57 echo
60 stop() {
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
64 done
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
69 done
72 if [ $RETVAL -eq 0 ]; then
73 success "$prog shutdown"
74 rm -f /var/lock/subsys/$prog
75 else
76 failure "$prog shutdown"
78 echo
81 restart() {
82 stop
83 start
86 save() {
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
98 chmod 0600 $oldtable
99 mv -f $oldtable $oldtable.save
100 done
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
106 done
109 if [ $RETVAL -eq 0 ]; then
110 success "$prog saved"
111 else
112 failure "$prog saved"
114 echo
117 case "$1" in
118 start)
119 start
121 stop)
122 [ "$EBTABLES_SAVE_ON_STOP" = "yes" ] && save
123 stop
125 restart|reload)
126 [ "$EBTABLES_SAVE_ON_RESTART" = "yes" ] && save
127 restart
129 condrestart)
130 [ -e /var/lock/subsys/$prog ] && restart
131 RETVAL=$?
133 save)
134 save
136 status)
137 __EXEC_PATH__/ebtables-save
138 RETVAL=$?
141 echo $"Usage $0 {start|stop|restart|condrestart|save|status}"
142 RETVAL=1
143 esac
145 exit $RETVAL