Blame SOURCES/ebtables-save

8c7451
#!/bin/bash
8c7451
8c7451
EBTABLES="/sbin/ebtables"
8c7451
8c7451
[ -x "$EBTABLES" ] || exit 1
8c7451
8c7451
echo "# Generated by ebtables-save v1.0 on $(date)"
8c7451
8c7451
cnt=""
8c7451
[ "x$EBTABLES_SAVE_COUNTER" = "xyes" ] && cnt="--Lc"
8c7451
8c7451
for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
8c7451
    table=$($EBTABLES -t $table_name -L $cnt)
8c7451
    [ $? -eq 0 ] || { echo "$table"; exit -1; }
8c7451
8c7451
    chain=""
8c7451
    rules=""
8c7451
    while read line; do
8c7451
	[ -z "$line" ] && continue
8c7451
8c7451
	case "$line" in 
8c7451
	    Bridge\ table:\ *)
8c7451
		echo "*${line:14}"
8c7451
		;;
8c7451
	    Bridge\ chain:\ *)
8c7451
		chain="${line:14}"
8c7451
		chain="${chain%%,*}"
8c7451
		policy="${line##*policy: }"
8c7451
		echo ":$chain $policy"
8c7451
		;;
8c7451
	    *)
8c7451
		if [ "$cnt" = "--Lc" ]; then
8c7451
		    line=${line/, pcnt \=/ -c}
8c7451
		    line=${line/-- bcnt \=/}
8c7451
		fi
8c7451
		rules="$rules-A $chain $line\n"
8c7451
		;;
8c7451
	esac
8c7451
    done <
8c7451
$table
8c7451
EOF
8c7451
    echo -e $rules
8c7451
done