Fix braindead 'echo' logic; more clean up of generated code

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4775 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2006-11-01 00:29:10 +00:00
parent 325da6543d
commit 4ce4363e00
5 changed files with 50 additions and 14 deletions

View File

@ -896,8 +896,11 @@ setup_tc1() {
#
# Just in case the file ended with a comment
#
[ -n "$COMMENTS" ] && save_command COMMENT=
if [ -n "$COMMENTS" ]; then
save_command
save_command COMMENT=
save_command
fi
#
# Link to the TC mangle chains from the main chains
#
@ -1005,7 +1008,7 @@ refresh_tc() {
#
indent >&3 << __EOF__
$IPTABLES -t mangle -L -n | grep '^Chain excl_' | while read junk chain rest; do
\$IPTABLES -t mangle -L -n | grep '^Chain excl_' | while read junk chain rest; do
run_iptables -t mangle -F \$chain
run_iptables -t mangle -X \$chain
done
@ -1035,7 +1038,11 @@ __EOF__
#
# Just in case the file ended with a comment
#
[ -n "$COMMENTS" ] && save_command COMMENT=
if [ -n "$COMMENTS" ]; then
save_command
save_command COMMENT=
save_command
fi
if [ -n "$TC_SCRIPT" ]; then
save_progress_message "Refreshing Traffic Shaping"
@ -2834,8 +2841,11 @@ process_rules()
#
# Just in case the file ended with a comment
#
[ -n "$COMMENTS" ] && save_command COMMENT=
if [ -n "$COMMENTS" ]; then
save_command
save_command COMMENT=
fi
case $SECTION in
ESTABLISHED)
finish_section ESTABLISHED,RELATED
@ -4894,6 +4904,17 @@ __EOF__
fi
}
#
# Hack to fix up generated object
#
prepare_source()
{
awk \
'BEGIN {blnk=0;}; \
/^\s*$/ {blnk=1; next; }; \
{ if (blnk == 1 ) print ""; blnk=0; print; }' -
}
#
# Compile a Firewall Script
#
@ -5181,6 +5202,7 @@ __EOF__
STOPPING=
COMMENT=
#
# The library requires that ${VARDIR} exist
#
@ -5613,7 +5635,7 @@ __EOF__
progress_message3 "Shorewall configuration verified"
else
INDENT=
cat $(find_file prog.header) $OUTPUT $(find_file prog.footer) > $outfile
cat $(find_file prog.header) $OUTPUT $(find_file prog.footer) | prepare_source > $outfile
chmod 700 $outfile
if [ -n "$EXPORT" ]; then
exec 3>${outfile}.conf

View File

@ -841,6 +841,9 @@ process_action3() {
fi
done < $TMP_DIR/$f
[ -n "$COMMENTS" ] && save_command COMMENT=
if [ -n "$COMMENTS" ]; then
save_command
save_command COMMENT=
fi
}

View File

@ -1355,18 +1355,20 @@ restore_default_route() {
#
# Determine how to do "echo -e"
#
find_echo() {
local result
result=$(echo "a\tb")
[ ${#result} -eq 3 ] && echo echo
[ ${#result} -eq 3 ] && { echo echo; return; }
result=$(echo -e "a\tb")
[ ${#result} -eq 3 ] && echo "echo -e"
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
result=$(which echo)
[ -n "$result" ] && echo "$result -e"
[ -n "$result" ] && { echo "$result -e"; return; }
echo echo
}

View File

@ -450,7 +450,11 @@ __EOF__
#
# Just in case the file ended with a comment
#
[ -n "$COMMENTS" ] && save_command COMMENT=
if [ -n "$COMMENTS" ]; then
save_command
save_command COMMENT=
save_command
fi
fi
}
@ -540,7 +544,11 @@ setup_nat() {
progress_message_and_save " Host $internal NAT $external on $interface"
done < $TMP_DIR/nat
[ -n "$COMMENTS" ] && save_command COMMENT=
if [ -n "$COMMENTS" ]; then
save_command
save_command COMMENT=
save_command
fi
fi
}

View File

@ -383,7 +383,7 @@ ${INDENT}cat > /etc/iproute2/rt_tables <<EOF
#
EOF
echocommand=\$(find_echo)
${INDENT}echocommand=\$(find_echo)
__EOF__
for table in $PROVIDERS; do
eval number=\$${table}_number
@ -411,6 +411,7 @@ __EOF__
fi
fi
save_command
save_command "run_ip route flush cache"
INDENT="$save_indent"
save_command "fi"