ebtables.sysv diff

Michal Soltys <[email protected]> Fri, 25 Jan 2008 19:18:33 +0100
Newsgroups gmane.linux.network.bridge.ebtables.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------090606070305020903090702
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit

Hello

While adapting init script for Archlinux, I noticed two small bugs in it:

- in two places where variables were tested, IPTABLES_* were used instead of
   EBTABLES_*

- if user chooses to save both text and binary formats, start function
   will try to use table 'save' in one loop iteration. It's not
   critical, but can be confusing for less experienced users.

Apart for that, few trivial changes - cut and sed "merged" into one sed
call, ls quiet on stderr. Diff in attachment.



--------------090606070305020903090702
Content-Type: text/plain;
 name="ebtables.sysv.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ebtables.sysv.diff"

--- ebtables.sysv	2008-01-24 23:14:52.000000000 +0100
+++ ebtables.sysv.new	2008-01-25 17:42:06.000000000 +0100
@@ -41,7 +41,7 @@
 start() {
 	echo -n $"Starting $desc ($prog): "
 	if [ "$EBTABLES_BINARY_FORMAT" = "yes" ]; then
-		for table in $(ls __SYSCONFIG__/ebtables.* | sed s/.*ebtables.//); do
+		for table in $(ls __SYSCONFIG__/ebtables.* 2>/dev/null | sed -e 's/.*ebtables\.//' -e '/save/d' ); do
 			__EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-commit || RETVAL=1
 		done
 	else
@@ -59,7 +59,7 @@
 
 stop() {
 	echo -n $"Stopping $desc ($prog): "
-	for table in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
+	for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
 		__EXEC_PATH__/ebtables -t $table --init-table || RETVAL=1
 	done
 
@@ -94,13 +94,11 @@
 	fi
 	if [ "$EBTABLES_BINARY_FORMAT" = "yes" ]; then
 		rm -f __SYSCONFIG__/ebtables.*.save
-		for oldtable in $(ls __SYSCONFIG__/ebtables.*); do
-			if [ "$oldtable" !=  __SYSCONFIG__/ebtables.save ]; then
-				chmod 0600 $oldtable
-				mv -f $oldtable $oldtable.save
-			fi
+		for oldtable in $(ls __SYSCONFIG__/ebtables.* 2>/dev/null | grep -vF 'ebtables.save'); do
+			chmod 0600 $oldtable
+			mv -f $oldtable $oldtable.save
 		done
-		for table in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
+		for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
 			__EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-save || RETVAL=1
 			if [ "$EBTABLES_SAVE_COUNTER" = "no" ]; then
 				__EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table -Z || RETVAL=1
@@ -121,11 +119,11 @@
 	start
 	;;
   stop)
-	[ "$IPTABLES_SAVE_ON_STOP" = "yes" ] && save
+	[ "$EBTABLES_SAVE_ON_STOP" = "yes" ] && save
 	stop
 	;;
   restart|reload)
-	[ "$IPTABLES_SAVE_ON_RESTART" = "yes" ] && save
+	[ "$EBTABLES_SAVE_ON_RESTART" = "yes" ] && save
 	restart
 	;;
   condrestart)

--------------090606070305020903090702
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--------------090606070305020903090702
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Ebtables-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ebtables-devel

--------------090606070305020903090702--