2004-01-31 17:11:22 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Script to install Shoreline Firewall
|
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm]
|
|
|
|
#
|
|
|
|
# (c) 2000,2001,2002,2003,2004 - Tom Eastep (teastep@shorewall.net)
|
|
|
|
#
|
|
|
|
# Seawall documentation is available at http://seawall.sourceforge.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
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# If you are running a distribution that has a directory called /etc/rc.d/init.d or one
|
|
|
|
# called /etc/init.d or you are running Slackware then simply cd to the directory
|
|
|
|
# containing this script and run it.
|
|
|
|
#
|
|
|
|
# ./install.sh
|
|
|
|
#
|
|
|
|
# If you don't have either of those directories, you will need to determine where the
|
|
|
|
# SysVInit scripts are kept on your system and pass the name of that directory.
|
|
|
|
#
|
|
|
|
# ./install.sh /etc/rc.d/scripts
|
|
|
|
#
|
|
|
|
# The default is that the firewall will be started in run levels 2-5 starting at
|
|
|
|
# position 15 and stopping at position 90. This is correct RedHat/Mandrake, Debian,
|
|
|
|
# Caldera and Corel.
|
|
|
|
#
|
|
|
|
# If you wish to change that, you can pass -r "<levels startpos stoppos>".
|
|
|
|
#
|
|
|
|
# Example 1: You wish to start your firewall in runlevels 2 and three, start at position
|
|
|
|
# 15 and stop at position 90
|
|
|
|
#
|
|
|
|
# ./install.sh -r "23 15 90"
|
|
|
|
#
|
|
|
|
# Example 2: You wish to start your firewall only in run level 3, start at position 5
|
|
|
|
# and stop at position 95.
|
|
|
|
#
|
|
|
|
# ./install.sh -r "3 5 95" /etc/rc.d/scripts
|
|
|
|
#
|
|
|
|
# For distributions that don't include chkconfig (Slackware, for example), the
|
|
|
|
# /etc/rc.d/rc.local file is modified to start the firewall.
|
|
|
|
#
|
|
|
|
|
2004-02-01 23:50:45 +01:00
|
|
|
VERSION=2.0.0-Alpha2
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
usage() # $1 = exit status
|
|
|
|
{
|
|
|
|
ME=`basename $0`
|
|
|
|
echo "usage: $ME [ -r \"<chkconfig parameters>\" ] [ <init scripts directory> ]"
|
|
|
|
echo " $ME [ -v ]"
|
|
|
|
echo " $ME [ -h ]"
|
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
run_install()
|
|
|
|
{
|
|
|
|
if ! install $*; then
|
|
|
|
echo
|
|
|
|
echo "ERROR: Failed to install $*"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
cant_autostart()
|
|
|
|
{
|
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "WARNING: Unable to configure Shorewall2 to start"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " automatically at boot"
|
|
|
|
}
|
|
|
|
|
|
|
|
backup_file() # $1 = file to backup
|
|
|
|
{
|
|
|
|
if [ -z "$PREFIX" -a -f $1 -a ! -f ${1}-${VERSION}.bkout ]; then
|
|
|
|
if (cp $1 ${1}-${VERSION}.bkout); then
|
|
|
|
echo
|
|
|
|
echo "$1 saved to ${1}-${VERSION}.bkout"
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
delete_file() # $1 = file to delete
|
|
|
|
{
|
|
|
|
if [ -z "$PREFIX" -a -f $1 -a ! -f ${1}-${VERSION}.bkout ]; then
|
|
|
|
if (mv $1 ${1}-${VERSION}.bkout); then
|
|
|
|
echo
|
|
|
|
echo "$1 moved to ${1}-${VERSION}.bkout"
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_file_with_backup() # $1 = source $2 = target $3 = mode
|
|
|
|
{
|
|
|
|
backup_file $2
|
|
|
|
run_install -o $OWNER -g $GROUP -m $3 $1 ${2}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Parse the run line
|
|
|
|
#
|
|
|
|
# DEST is the SysVInit script directory
|
|
|
|
# RUNLEVELS is the chkconfig parmeters for firewall
|
|
|
|
# ARGS is "yes" if we've already parsed an argument
|
|
|
|
#
|
|
|
|
DEST=""
|
|
|
|
RUNLEVELS=""
|
|
|
|
ARGS=""
|
|
|
|
|
|
|
|
if [ -z "$OWNER" ] ; then
|
|
|
|
OWNER=root
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$GROUP" ] ; then
|
|
|
|
GROUP=root
|
|
|
|
fi
|
|
|
|
|
|
|
|
while [ $# -gt 0 ] ; do
|
|
|
|
case "$1" in
|
|
|
|
-h|help|?)
|
|
|
|
if [ -n "$ARGS" ]; then
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
-r)
|
|
|
|
if [ -n "$RUNLEVELS" -o $# -eq 1 ]; then
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
RUNLEVELS="$2";
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-v)
|
|
|
|
if [ -n "$ARGS" ]; then
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Shorewall Firewall Installer Version $VERSION"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -n "$DEST" ]; then
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
DEST="$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
ARGS="yes"
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
|
|
|
|
|
|
|
if [ -z "$DEST" ]; then
|
|
|
|
DEST=/etc/init.d
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine where to install the firewall script
|
|
|
|
#
|
2004-02-01 23:50:45 +01:00
|
|
|
DEBIAN=
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
if [ -n "$PREFIX" ]; then
|
|
|
|
install -d -o $OWNER -g $GROUP -m 755 ${PREFIX}/sbin
|
|
|
|
install -d -o $OWNER -g $GROUP -m 755 ${PREFIX}${DEST}
|
2004-02-01 23:50:45 +01:00
|
|
|
elif [ -d /etc/apt -a -e /usr/bin/dpkg ]; then
|
|
|
|
DEBIAN=yes
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
|
2004-01-31 19:06:14 +01:00
|
|
|
FIREWALL="shorewall2"
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Change to the directory containing this script
|
|
|
|
#
|
|
|
|
cd "`dirname $0`"
|
|
|
|
|
|
|
|
echo "Installing Shorewall Version $VERSION"
|
|
|
|
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
# Check for /etc/shorewall2
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -d ${PREFIX}/etc/shorewall2 ]; then
|
2004-01-31 17:11:22 +01:00
|
|
|
first_install=""
|
|
|
|
else
|
|
|
|
first_install="Yes"
|
|
|
|
fi
|
|
|
|
|
2004-01-31 19:06:14 +01:00
|
|
|
install_file_with_backup shorewall ${PREFIX}/sbin/shorewall2 0544
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Shorewall2 control program installed in ${PREFIX}/sbin/shorewall2"
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Firewall Script
|
|
|
|
#
|
2004-02-02 00:21:10 +01:00
|
|
|
if [ -n "$DEBIAN" ]; then
|
|
|
|
install_file_with_backup init.debian.sh /etc/init.d/shorewall2
|
|
|
|
else
|
|
|
|
install_file_with_backup init.sh ${PREFIX}${DEST}/$FIREWALL 0544
|
|
|
|
fi
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Shorewall script installed in ${PREFIX}${DEST}/$FIREWALL"
|
|
|
|
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
# Create /etc/shorewall2, /usr/share/shorewall2 and /var/shorewall if needed
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
mkdir -p ${PREFIX}/etc/shorewall2
|
|
|
|
mkdir -p ${PREFIX}/usr/share/shorewall2
|
2004-01-31 17:11:22 +01:00
|
|
|
mkdir -p ${PREFIX}/var/lib/shorewall
|
|
|
|
#
|
|
|
|
# Install the config file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/shorewall.conf ]; then
|
|
|
|
backup_file /etc/shorewall2/shorewall.conf
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0744 shorewall.conf ${PREFIX}/etc/shorewall2/shorewall.conf
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Config file installed as ${PREFIX}/etc/shorewall2/shorewall.conf"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the zones file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/zones ]; then
|
|
|
|
backup_file /etc/shorewall2/zones
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0744 zones ${PREFIX}/etc/shorewall2/zones
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Zones file installed as ${PREFIX}/etc/shorewall2/zones"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install the functions file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/functions ]; then
|
|
|
|
backup_file ${PREFIX}/etc/shorewall2/functions
|
|
|
|
rm -f ${PREFIX}/etc/shorewall2/functions
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
|
2004-01-31 19:06:14 +01:00
|
|
|
install_file_with_backup functions ${PREFIX}/usr/share/shorewall2/functions 0444
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Common functions installed in ${PREFIX}/usr/share/shorewall2/functions"
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Help file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
install_file_with_backup help ${PREFIX}/usr/share/shorewall2/help 0544
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Help command executor installed in ${PREFIX}/usr/share/shorewall2/help"
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# Install the common.def file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
install_file_with_backup common.def ${PREFIX}/etc/shorewall2/common.def 0444
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Common rules installed in ${PREFIX}/etc/shorewall2/common.def"
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Delete the icmp.def file
|
|
|
|
#
|
|
|
|
delete_file icmp.def
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install the policy file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/policy ]; then
|
|
|
|
backup_file /etc/shorewall2/policy
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 policy ${PREFIX}/etc/shorewall2/policy
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Policy file installed as ${PREFIX}/etc/shorewall2/policy"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the interfaces file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/interfaces ]; then
|
|
|
|
backup_file /etc/shorewall2/interfaces
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 interfaces ${PREFIX}/etc/shorewall2/interfaces
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Interfaces file installed as ${PREFIX}/etc/shorewall2/interfaces"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the hosts file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/hosts ]; then
|
|
|
|
backup_file /etc/shorewall2/hosts
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 hosts ${PREFIX}/etc/shorewall2/hosts
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Hosts file installed as ${PREFIX}/etc/shorewall2/hosts"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the rules file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/rules ]; then
|
|
|
|
backup_file /etc/shorewall2/rules
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 rules ${PREFIX}/etc/shorewall2/rules
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Rules file installed as ${PREFIX}/etc/shorewall2/rules"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the NAT file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/nat ]; then
|
|
|
|
backup_file /etc/shorewall2/nat
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 nat ${PREFIX}/etc/shorewall2/nat
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "NAT file installed as ${PREFIX}/etc/shorewall2/nat"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Parameters file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/params ]; then
|
|
|
|
backup_file /etc/shorewall2/params
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 params ${PREFIX}/etc/shorewall2/params
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Parameter file installed as ${PREFIX}/etc/shorewall2/params"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the proxy ARP file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/proxyarp ]; then
|
|
|
|
backup_file /etc/shorewall2/proxyarp
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 proxyarp ${PREFIX}/etc/shorewall2/proxyarp
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Proxy ARP file installed as ${PREFIX}/etc/shorewall2/proxyarp"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Stopped Routing file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/routestopped ]; then
|
|
|
|
backup_file /etc/shorewall2/routestopped
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 routestopped ${PREFIX}/etc/shorewall2/routestopped
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Stopped Routing file installed as ${PREFIX}/etc/shorewall2/routestopped"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Mac List file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/maclist ]; then
|
|
|
|
backup_file /etc/shorewall2/maclist
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 maclist ${PREFIX}/etc/shorewall2/maclist
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "MAC list file installed as ${PREFIX}/etc/shorewall2/maclist"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Masq file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/masq ]; then
|
|
|
|
backup_file /etc/shorewall2/masq
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 masq ${PREFIX}/etc/shorewall2/masq
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Masquerade file installed as ${PREFIX}/etc/shorewall2/masq"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Modules file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/modules ]; then
|
|
|
|
backup_file /etc/shorewall2/modules
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 modules ${PREFIX}/etc/shorewall2/modules
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Modules file installed as ${PREFIX}/etc/shorewall2/modules"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the TC Rules file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/tcrules ]; then
|
|
|
|
backup_file /etc/shorewall2/tcrules
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 tcrules ${PREFIX}/etc/shorewall2/tcrules
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "TC Rules file installed as ${PREFIX}/etc/shorewall2/tcrules"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install the TOS file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/tos ]; then
|
|
|
|
backup_file /etc/shorewall2/tos
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 tos ${PREFIX}/etc/shorewall2/tos
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "TOS file installed as ${PREFIX}/etc/shorewall2/tos"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Tunnels file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/tunnels ]; then
|
|
|
|
backup_file /etc/shorewall2/tunnels
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 tunnels ${PREFIX}/etc/shorewall2/tunnels
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Tunnels file installed as ${PREFIX}/etc/shorewall2/tunnels"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the blacklist file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/blacklist ]; then
|
|
|
|
backup_file /etc/shorewall2/blacklist
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 blacklist ${PREFIX}/etc/shorewall2/blacklist
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Blacklist file installed as ${PREFIX}/etc/shorewall2/blacklist"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Backup and remove the whitelist file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/whitelist ]; then
|
|
|
|
backup_file /etc/shorewall2/whitelist
|
|
|
|
rm -f ${PREFIX}/etc/shorewall2/whitelist
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the rfc1918 file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/rfc1918 ]; then
|
|
|
|
backup_file /etc/shorewall2/rfc1918
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 rfc1918 ${PREFIX}/etc/shorewall2/rfc1918
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "RFC 1918 file installed as ${PREFIX}/etc/shorewall2/rfc1918"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the init file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/init ]; then
|
|
|
|
backup_file /etc/shorewall2/init
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 init ${PREFIX}/etc/shorewall2/init
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Init file installed as ${PREFIX}/etc/shorewall2/init"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the start file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/start ]; then
|
|
|
|
backup_file /etc/shorewall2/start
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 start ${PREFIX}/etc/shorewall2/start
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Start file installed as ${PREFIX}/etc/shorewall2/start"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the stop file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/stop ]; then
|
|
|
|
backup_file /etc/shorewall2/stop
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 stop ${PREFIX}/etc/shorewall2/stop
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Stop file installed as ${PREFIX}/etc/shorewall2/stop"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the stopped file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/stopped ]; then
|
|
|
|
backup_file /etc/shorewall2/stopped
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 stopped ${PREFIX}/etc/shorewall2/stopped
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Stopped file installed as ${PREFIX}/etc/shorewall2/stopped"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the ECN file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/ecn ]; then
|
|
|
|
backup_file /etc/shorewall2/ecn
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 ecn ${PREFIX}/etc/shorewall2/ecn
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "ECN file installed as ${PREFIX}/etc/shorewall2/ecn"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the Accounting file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/accounting ]; then
|
|
|
|
backup_file /etc/shorewall2/accounting
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 accounting ${PREFIX}/etc/shorewall2/accounting
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Accounting file installed as ${PREFIX}/etc/shorewall2/accounting"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Install the Actions file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/actions ]; then
|
|
|
|
backup_file /etc/shorewall2/actions
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-01-31 19:06:14 +01:00
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 actions ${PREFIX}/etc/shorewall2/actions
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Actions file installed as ${PREFIX}/etc/shorewall2/actions"
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
# Install the Action files
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
for f in action.* ; do
|
|
|
|
if [ -f ${PREFIX}/etc/shorewall2/$f ]; then
|
|
|
|
backup_file /etc/shorewall2/$f
|
|
|
|
else
|
|
|
|
run_install -o $OWNER -g $GROUP -m 0600 $f ${PREFIX}/etc/shorewall2/$f
|
|
|
|
echo
|
|
|
|
echo "Action ${f#*.} file installed as ${PREFIX}/etc/shorewall2/$f"
|
|
|
|
fi
|
|
|
|
done
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# Backup the version file
|
|
|
|
#
|
|
|
|
if [ -z "$PREFIX" ]; then
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -f /usr/share/shorewall2/version ]; then
|
|
|
|
backup_file /usr/share/shorewall2/version
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Create the version file
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "$VERSION" > ${PREFIX}/usr/share/shorewall2/version
|
|
|
|
chmod 644 ${PREFIX}/usr/share/shorewall2/version
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# Remove and create the symbolic link to the init script
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ -z "$PREFIX" ]; then
|
2004-01-31 19:06:14 +01:00
|
|
|
rm -f /usr/share/shorewall2/init
|
|
|
|
ln -s ${DEST}/${FIREWALL} /usr/share/shorewall2/init
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Install the firewall script
|
|
|
|
#
|
2004-01-31 19:06:14 +01:00
|
|
|
install_file_with_backup firewall ${PREFIX}/usr/share/shorewall2/firewall 0544
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ -z "$PREFIX" -a -n "$first_install" ]; then
|
2004-01-31 19:06:14 +01:00
|
|
|
if [ -n "$DEBIAN" ]; then
|
|
|
|
run_install -o $OWNER -g $GROUP -m 0644 default.debian /etc/default/shorewall2
|
|
|
|
ln -s ../init.d/shorewall2 /etc/rcS.d/S40shorewall2
|
|
|
|
echo
|
|
|
|
echo "Shorewall2 will start automatically at boot"
|
2004-02-01 23:50:45 +01:00
|
|
|
echo "Set startup=1 in /etc/default/shorewall2 to enable"
|
2004-01-31 19:06:14 +01:00
|
|
|
else
|
|
|
|
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
|
|
|
|
if insserv /etc/init.d/shorewalls ; then
|
|
|
|
echo
|
|
|
|
echo "Shorewall2 will start automatically at boot"
|
2004-02-01 23:50:45 +01:00
|
|
|
echo "Remove /etc/shorewall2/startup_disabled in /etc/default/shorewall2 to enable"
|
2004-01-31 19:06:14 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
|
|
|
|
if chkconfig --add shorewall2 ; then
|
|
|
|
echo
|
|
|
|
echo "Shorewall2 will start automatically in run levels as follows:"
|
2004-02-01 23:50:45 +01:00
|
|
|
echo "Remove /etc/shorewall2/startup_disabled in /etc/default/shorewall2 to enable"
|
2004-01-31 19:06:14 +01:00
|
|
|
chkconfig --list $FIREWALL
|
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ -x /sbin/rc-update ]; then
|
|
|
|
if rc-update add shorewall2 default; then
|
|
|
|
echo
|
|
|
|
echo "Shorewall2 will start automatically at boot"
|
2004-02-01 23:50:45 +01:00
|
|
|
echo "Remove /etc/shorewall2/startup_disabled in /etc/default/shorewall2 to enable"
|
2004-01-31 19:06:14 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo \
|
|
|
|
"########################################################################
|
|
|
|
# REMOVE THIS FILE AFTER YOU HAVE CONFIGURED SHOREWALL #
|
2004-01-31 19:06:14 +01:00
|
|
|
########################################################################" > /etc/shorewall2/startup_disabled
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Report Success
|
|
|
|
#
|
|
|
|
echo
|
2004-01-31 19:06:14 +01:00
|
|
|
echo "Shorewall2 Version $VERSION Installed"
|