From 4a26e098be9da8feb00b930e6985a668bbec6117 Mon Sep 17 00:00:00 2001 From: teastep Date: Sun, 27 Aug 2006 18:16:55 +0000 Subject: [PATCH] Begin modularization again git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4450 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/compiler | 8 +++++++ Shorewall/functions | 43 +++++++++++++++++++++++++++++++------- Shorewall/lib.dynamiczones | 28 +++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 Shorewall/lib.dynamiczones diff --git a/Shorewall/compiler b/Shorewall/compiler index 5c02b75cf..5226b31a4 100755 --- a/Shorewall/compiler +++ b/Shorewall/compiler @@ -8270,6 +8270,14 @@ __EOF__ } +# +# Give Usage Information +# +usage() { + echo "Usage: $0 [debug] check|compile }" + exit 1 +} + # # E X E C U T I O N B E G I N S H E R E # diff --git a/Shorewall/functions b/Shorewall/functions index 0cd9a5ea2..df85c7790 100644 --- a/Shorewall/functions +++ b/Shorewall/functions @@ -1742,6 +1742,41 @@ strip_file() # $1 = Base Name of the file, $2 = Full Name of File (optional) fi } +# +# Load an optional library +# +lib_load() # $1 = Name of the Library, $2 = Error Message heading if the library cannot be found +{ + local lib=${SHAREDIR}/lib.$1 + local loaded + + eval loaded=\$LIB_${1}_LOADED + + if [ -z "$loaded" ]; then + if [ -f $lib ]; then + . $lib + eval LIB_${1}_LOADED=Yes + else + startup_error "$2 requires the Shorewall library $1 ($lib) which is not installed" + fi + fi +} + +# +# Determine if an optional library is available +# +lib_avail() # $1 = Name of the Library +{ + [ -f ${SHAREDIR}/lib.$1 ] +} + +strip_file_and_lib_load() # $1 = logical file name, $3 = Error message heading if the library cannot be found +{ + strip_file $1 + + [ -s $TMP_DIR/$1 ] && lib_load $2 "$3" +} + # # Note: The following set of IP address manipulation functions have anomalous # behavior when the shell only supports 32-bit signed arithmatic and @@ -3125,12 +3160,4 @@ do_initialize() { qt mywhich awk && HAVEAWK=Yes || HAVEAWK= } -# -# Give Usage Information -# -usage() { - echo "Usage: $0 [debug] check|compile }" - exit 1 -} - SHOREWALL_LIBRARY=Loaded diff --git a/Shorewall/lib.dynamiczones b/Shorewall/lib.dynamiczones new file mode 100644 index 000000000..f11059795 --- /dev/null +++ b/Shorewall/lib.dynamiczones @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Shorewall 3.2 -- /usr/share/shorewall/lib.dynamicrules +# +# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm] +# +# (c) 1999,2000,2001,2002,2003,2004,2005,2006 - Tom Eastep (teastep@shorewall.net) +# +# tcstart from tc4shorewall Version 0.5 +# (c) 2005 Arne Bernin +# Modified by Tom Eastep for integration into the Shorewall distribution +# published under GPL Version 2# +# +# 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 +