2007-03-10 02:58:40 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2007-03-16 00:18:58 +01:00
|
|
|
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall Compiler wrapper - V3.9
|
2007-03-10 02:58:40 +01:00
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm]
|
|
|
|
#
|
|
|
|
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007 - Tom Eastep (teastep@shorewall.net)
|
|
|
|
#
|
|
|
|
# Complete documentation is available at http://shorewall.net
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of Version 2 of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
|
|
|
|
#
|
|
|
|
# Commands are:
|
|
|
|
#
|
|
|
|
# compile check Verify the configuration files.
|
|
|
|
# compile compile <path name> Compile into <path name>
|
|
|
|
#
|
|
|
|
# Environmental Variables:
|
|
|
|
#
|
|
|
|
# EXPORT=Yes -e option specified to /sbin/shorewall
|
|
|
|
# SHOREWALL_DIR A directory name was passed to /sbin/shorewall
|
|
|
|
# VERBOSE Standard Shorewall verbosity control.
|
2007-03-16 00:18:58 +01:00
|
|
|
#
|
2007-03-10 02:58:40 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Fatal error -- stops the compiler after issuing the error message
|
|
|
|
#
|
|
|
|
fatal_error() # $* = Error Message
|
|
|
|
{
|
|
|
|
echo " ERROR: $@" >&2
|
|
|
|
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
|
|
|
|
[ -n "$OUTPUT" ] && rm -f $OUTPUT
|
|
|
|
kill $$
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# We include this for compatibility with the 'firewall' script. That script distinguishes between
|
|
|
|
# Fatal Errors (stop or restore required) and Startup Errors (errors detected before the firewall
|
|
|
|
# state has been changed. This allows us to use common parsing routines in both programs.
|
|
|
|
#
|
|
|
|
startup_error()
|
|
|
|
{
|
|
|
|
echo " ERROR: $@" >&2
|
|
|
|
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
|
|
|
|
[ -n "$OUTPUT" ] && rm -f $OUTPUT
|
|
|
|
kill $$
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2007-03-10 20:39:57 +01:00
|
|
|
# Debug the compiler if first arg is "debug"
|
2007-03-10 02:58:40 +01:00
|
|
|
#
|
2007-03-10 20:39:57 +01:00
|
|
|
debug="-w"
|
2007-03-10 02:58:40 +01:00
|
|
|
|
2007-03-10 20:39:57 +01:00
|
|
|
[ $# -gt 1 ] && [ "$1" = "debug" ] && { debug="-dw"; shift ; }
|
2007-03-10 02:58:40 +01:00
|
|
|
|
|
|
|
SHAREDIR=/usr/share/shorewall
|
|
|
|
VARDIR=/var/lib/shorewall
|
|
|
|
[ -z "$EXPORT" ] && CONFDIR=/etc/shorewall || CONFDIR=${SHAREDIR}/configfiles
|
|
|
|
|
|
|
|
[ -n "${VERBOSE:=2}" ]
|
|
|
|
|
|
|
|
for library in lib.base lib.config; do
|
|
|
|
FUNCTIONS=${SHAREDIR}/${library}
|
|
|
|
|
|
|
|
if [ -f $FUNCTIONS ]; then
|
|
|
|
[ $VERBOSE -ge 2 ] && echo "Loading $FUNCTIONS..."
|
|
|
|
. $FUNCTIONS
|
|
|
|
else
|
|
|
|
fatal_error "Installation Error: $FUNCTIONS does not exist!"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
PROGRAM=compiler
|
|
|
|
|
|
|
|
COMMAND="$1"
|
|
|
|
|
|
|
|
case "$COMMAND" in
|
|
|
|
|
|
|
|
check)
|
|
|
|
[ $# -ne 1 ] && usage
|
|
|
|
do_initialize
|
2007-03-10 03:22:18 +01:00
|
|
|
exec perl $debug /usr/share/shorewall/compiler.pl
|
2007-03-10 02:58:40 +01:00
|
|
|
;;
|
|
|
|
compile)
|
|
|
|
[ $# -ne 2 ] && usage
|
|
|
|
do_initialize
|
2007-03-11 02:40:59 +01:00
|
|
|
exec perl $debug /usr/share/shorewall/compiler.pl $(resolve_file $2)
|
2007-03-10 02:58:40 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|