Pretty up generated code

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@3377 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2006-01-25 04:50:05 +00:00
parent 5727afc83b
commit df34d1f79b
2 changed files with 42 additions and 4 deletions

View File

@ -8034,6 +8034,9 @@ compile_stop_firewall() {
cat >> $OUTPUT << __EOF__ cat >> $OUTPUT << __EOF__
#
# Stop/restore the firewall after an error or because of a "stop" or "clear" command
#
stop_firewall() { stop_firewall() {
deletechain() { deletechain() {
@ -8340,10 +8343,16 @@ __EOF__
cat >> $OUTPUT << __EOF__ cat >> $OUTPUT << __EOF__
#
# Set policy of chain \$1 to \$2
#
setpolicy() { setpolicy() {
\$IPTABLES -P \$1 \$2 \$IPTABLES -P \$1 \$2
} }
#
# Remove all Shorewall-added rules
#
clear_firewall() { clear_firewall() {
stop_firewall stop_firewall
@ -8375,6 +8384,9 @@ __EOF__
logger "Shorewall Cleared" logger "Shorewall Cleared"
} }
#
# Issue a message and stop/restore the firewall
#
fatal_error() fatal_error()
{ {
echo " ERROR: \$@" >&2 echo " ERROR: \$@" >&2
@ -8382,6 +8394,9 @@ fatal_error()
exit 2 exit 2
} }
#
# Issue a message and stop
#
startup_error() # $* = Error Message startup_error() # $* = Error Message
{ {
echo " ERROR: \$@" >&2 echo " ERROR: \$@" >&2
@ -8389,6 +8404,9 @@ startup_error() # $* = Error Message
exit 2 exit 2
} }
#
# Run iptables and if an error occurs, stop/restore the firewall
#
run_iptables() run_iptables()
{ {
if ! \$IPTABLES \$@; then if ! \$IPTABLES \$@; then
@ -8398,6 +8416,9 @@ run_iptables()
fi fi
} }
#
# Run iptables and if an error occurs, stop/restore the firewall
#
run_ip() run_ip()
{ {
if ! ip \$@; then if ! ip \$@; then
@ -8407,6 +8428,9 @@ run_ip()
fi fi
} }
#
# Run tc and if an error occurs, stop/restore the firewall
#
run_tc() { run_tc() {
if ! tc \$@ ; then if ! tc \$@ ; then
error_message "ERROR: Command \"tc \$@\" Failed" error_message "ERROR: Command \"tc \$@\" Failed"
@ -8415,6 +8439,9 @@ run_tc() {
fi fi
} }
#
# Initialize environment
#
initialize() { initialize() {
__EOF__ __EOF__
if [ -z "$EXPORT" ]; then if [ -z "$EXPORT" ]; then
@ -8467,8 +8494,12 @@ __EOF__
[ -d /var/lib/shorewall ] || mkdir -p /var/lib/shorewall [ -d /var/lib/shorewall ] || mkdir -p /var/lib/shorewall
} }
#
# Start/Restart/Reload the firewall
#
define_firewall() {}
__EOF__ __EOF__
save_command "define_firewall() {"
INDENT=" " INDENT=" "
cat >> $OUTPUT << __EOF__ cat >> $OUTPUT << __EOF__
@ -8581,6 +8612,7 @@ __EOF__
else else
INDENT= INDENT=
save_command "}" save_command "}"
save_command ""
cat $(find_file prog.header) $OUTPUT $(find_file prog.footer) > $outfile cat $(find_file prog.header) $OUTPUT $(find_file prog.footer) > $outfile
chmod 700 $outfile chmod 700 $outfile
progress_message2 "Shorewall configuration compiled to $outfile" progress_message2 "Shorewall configuration compiled to $outfile"

View File

@ -1,3 +1,6 @@
#
# Define Firewall and ignore errors
#
restore_firewall() restore_firewall()
{ {
fatal_error() fatal_error()
@ -13,14 +16,17 @@ restore_firewall()
define_firewall define_firewall
} }
#
# Returns the fully-qualified name of this script
#
current_command() { current_command() {
cd $(dirname $0) cd $(dirname $0)
echo $PWD/$(basename $0) echo $PWD/$(basename $0)
} }
################################################################################ #
# Give Usage Information # # Give Usage Information
################################################################################ #
usage() { usage() {
echo "Usage: $0 [ -q ] [ -v ] [ -n ] [ start|stop|clear|reload|restart|status|restore|version ]" echo "Usage: $0 [ -q ] [ -v ] [ -n ] [ start|stop|clear|reload|restart|status|restore|version ]"
exit $1 exit $1