From dbe58ae8664bf77b94012890edadfa73ba774f47 Mon Sep 17 00:00:00 2001 From: teastep Date: Sat, 24 Mar 2007 22:26:32 +0000 Subject: [PATCH] Add installer git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5673 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- New/Shorewall/Chains.pm | 5 +- New/install.sh | 191 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+), 4 deletions(-) create mode 100755 New/install.sh diff --git a/New/Shorewall/Chains.pm b/New/Shorewall/Chains.pm index 14e2b1137..ad320df48 100644 --- a/New/Shorewall/Chains.pm +++ b/New/Shorewall/Chains.pm @@ -217,7 +217,6 @@ my $exclseq = 0; # # Used to suppress duplicate match specifications. # -my $ipsetmatch = 0; my $iprangematch = 0; # # Keep track of whether there are run-time commands in the chain rules @@ -271,7 +270,6 @@ sub add_rule($$) } $iprangematch = 0; - $ipsetmatch = 0; } # @@ -292,7 +290,6 @@ sub insert_rule($$$) $chainref->{referenced} = 1; $iprangematch = 0; - $ipsetmatch = 0; } # @@ -592,7 +589,7 @@ sub newexclusionchain() { } sub clearrule() { - $iprangematch = $ipsetmatch = 0; + $iprangematch = 0; } # diff --git a/New/install.sh b/New/install.sh new file mode 100755 index 000000000..3a9cbff70 --- /dev/null +++ b/New/install.sh @@ -0,0 +1,191 @@ +#!/bin/sh +# +# Script to install Shorewall-pl. +# +# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm] +# +# (c) 2007 - Tom Eastep (teastep@shorewall.net) +# +# Shorewall 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 +# + +VERSION=3.9.0-1 + +usage() # $1 = exit status +{ + ME=$(basename $0) + echo "usage: $ME" + echo " $ME -v" + echo " $ME -h" + echo " $ME -n" + exit $1 +} + +split() { + local ifs=$IFS + IFS=: + set -- $1 + echo $* + IFS=$ifs +} + +qt() +{ + "$@" >/dev/null 2>&1 +} + +mywhich() { + local dir + + for dir in $(split $PATH); do + if [ -x $dir/$1 ]; then + echo $dir/$1 + return 0 + fi + done + + return 2 +} + +run_install() +{ + if ! install $*; then + echo + echo "ERROR: Failed to install $*" >&2 + exit 1 + fi +} + +delete_file() # $1 = file to delete +{ + rm -f $1 +} + +install_file() # $1 = source $2 = target $3 = mode +{ + run_install $OWNERSHIP -m $3 $1 ${2} +} + +# +# Parse the run line +# +# DEST is the SysVInit script directory +# INIT is the name of the script in the $DEST directory +# RUNLEVELS is the chkconfig parmeters for firewall +# ARGS is "yes" if we've already parsed an argument +# +ARGS="" + +if [ -z "$DEST" ] ; then + DEST="/etc/init.d" +fi + +if [ -z "$INIT" ] ; then + INIT="shorewall" +fi + +if [ -z "$RUNLEVELS" ] ; then + RUNLEVELS="" +fi + +if [ -z "$OWNER" ] ; then + OWNER=root +fi + +if [ -z "$GROUP" ] ; then + GROUP=root +fi + +NOBACKUP= + +while [ $# -gt 0 ] ; do + case "$1" in + -h|help|?) + usage 0 + ;; + -v) + echo "Shorewall-pl Installer Version $VERSION" + exit 0 + ;; + -n) + NOBACKUP=Yes + ;; + *) + usage 1 + ;; + esac + shift + ARGS="yes" +done + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin + +OWNERSHIP="-o $OWNER -g $GROUP" + +if [ -n "$PREFIX" ]; then + if [ `id -u` != 0 ] ; then + echo "Not setting file owner/group permissions, not running as root." + OWNERSHIP="" + fi + + install -d $OWNERSHIP -m 755 ${PREFIX}/sbin + install -d $OWNERSHIP -m 755 ${PREFIX}${DEST} +fi + +# +# Change to the directory containing this script +# +cd "$(dirname $0)" + +echo "Installing Shorewall-pl Version $VERSION" + +# +# /usr/share/shorewall-pl if needed +# +mkdir -p ${PREFIX}/usr/share/shorewall-pl/Shorewall + +chmod 755 ${PREFIX}/usr/share/shorewall-pl +chmod 755 ${PREFIX}/usr/share/shorewall-pl/Shorewall + +# +# Install the Compiler +# + +install_file compiler.pl ${PREFIX}/usr/share/shorewall-pl/compiler.pl 0555 + +echo +echo "Compiler installed in ${PREFIX}/usr/share/shorewall-pl/compiler.pl" + +# +# Install the libraries +# +for f in Shorewall/*.pm ; do + install_file $f ${PREFIX}/usr/share/shorewall-pl/$f 0644 + echo "Library ${f%.*} file installed as ${PREFIX}/usr/share/shorewall-pl/$f" +done + +# +# Install the program skeleton files +# +for f in prog.* ; do + install_file $f ${PREFIX}/usr/share/shorewall-pl/$f 0644 + echo "Program skeleton file ${f#*.} installed as ${PREFIX}/usr/share/shorewall-pl/$f" +done + +# +# Report Success +# +echo "Shorewall-pl Version $VERSION Installed"