Blame SOURCES/ebtables-legacy-save

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