2008-12-09 17:50:17 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
# Script to install Shoreline Firewall 6 Lite
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
|
|
|
#
|
|
|
|
# (c) 2000,2001,2002,2003,2004,2005,2006,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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
|
2009-06-13 00:51:43 +02:00
|
|
|
VERSION=4.4.0-Beta1
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
cant_autostart()
|
|
|
|
{
|
|
|
|
echo
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "WARNING: Unable to configure shorewall6-lite to start automatically at boot" >&2
|
2008-12-09 17:50:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2008-12-10 01:33:55 +01:00
|
|
|
INIT="shorewall6-lite"
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$RUNLEVELS" ] ; then
|
|
|
|
RUNLEVELS=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$OWNER" ] ; then
|
|
|
|
OWNER=root
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$GROUP" ] ; then
|
|
|
|
GROUP=root
|
|
|
|
fi
|
|
|
|
|
|
|
|
while [ $# -gt 0 ] ; do
|
|
|
|
case "$1" in
|
|
|
|
-h|help|?)
|
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
-v)
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "Shorewall6 Lite Firewall Installer Version $VERSION"
|
2008-12-09 17:50:17 +01:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
ARGS="yes"
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine where to install the firewall script
|
|
|
|
#
|
|
|
|
DEBIAN=
|
|
|
|
|
|
|
|
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}
|
|
|
|
elif [ -d /etc/apt -a -e /usr/bin/dpkg ]; then
|
|
|
|
DEBIAN=yes
|
|
|
|
elif [ -f /etc/slackware-version ] ; then
|
|
|
|
DEST="/etc/rc.d"
|
|
|
|
INIT="rc.firewall"
|
|
|
|
elif [ -f /etc/arch-release ] ; then
|
|
|
|
DEST="/etc/rc.d"
|
2008-12-10 01:33:55 +01:00
|
|
|
INIT="shorewall6-lite"
|
2008-12-09 17:50:17 +01:00
|
|
|
ARCHLINUX=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Change to the directory containing this script
|
|
|
|
#
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "Installing Shorewall6 Lite Version $VERSION"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
# Check for /etc/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
if [ -z "$PREFIX" -a -d /etc/shorewall6-lite ]; then
|
2008-12-09 17:50:17 +01:00
|
|
|
first_install=""
|
2008-12-10 01:33:55 +01:00
|
|
|
[ -f /etc/shorewall6-lite/shorewall.conf ] && \
|
|
|
|
mv -f /etc/shorewall6-lite/shorewall.conf /etc/shorewall6-lite/shorewall6-lite.conf
|
2008-12-09 17:50:17 +01:00
|
|
|
else
|
|
|
|
first_install="Yes"
|
2008-12-10 01:33:55 +01:00
|
|
|
rm -rf ${PREFIX}/etc/shorewall6-lite
|
|
|
|
rm -rf ${PREFIX}/usr/share/shorewall6-lite
|
|
|
|
rm -rf ${PREFIX}/var/lib/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
delete_file ${PREFIX}/usr/share/shorewall6-lite/xmodules
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2009-02-22 22:06:51 +01:00
|
|
|
install_file shorewall6-lite ${PREFIX}/sbin/shorewall6-lite 0544 ${PREFIX}/var/lib/shorewall6-lite-${VERSION}.bkout
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "Shorewall6 Lite control program installed in ${PREFIX}/sbin/shorewall6-lite"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Firewall Script
|
|
|
|
#
|
|
|
|
if [ -n "$DEBIAN" ]; then
|
2009-02-22 22:06:51 +01:00
|
|
|
install_file init.debian.sh /etc/init.d/shorewall6-lite 0544 ${PREFIX}/usr/share/shorewall6-lite-${VERSION}.bkout
|
2008-12-09 17:50:17 +01:00
|
|
|
elif [ -n "$ARCHLINUX" ]; then
|
2009-02-22 22:06:51 +01:00
|
|
|
install_file init.archlinux.sh ${PREFIX}${DEST}/$INIT 0544 ${PREFIX}/usr/share/shorewall6-lite-${VERSION}.bkout
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
else
|
2009-02-22 22:06:51 +01:00
|
|
|
install_file init.sh ${PREFIX}${DEST}/$INIT 0544 ${PREFIX}/usr/share/shorewall6-lite-${VERSION}.bkout
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "Shorewall6 Lite script installed in ${PREFIX}${DEST}/$INIT"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
# Create /etc/shorewall6-lite, /usr/share/shorewall6-lite and /var/lib/shorewall6-lite if needed
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
mkdir -p ${PREFIX}/etc/shorewall6-lite
|
|
|
|
mkdir -p ${PREFIX}/usr/share/shorewall6-lite
|
|
|
|
mkdir -p ${PREFIX}/var/lib/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
chmod 755 ${PREFIX}/etc/shorewall6-lite
|
|
|
|
chmod 755 ${PREFIX}/usr/share/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the config file
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
if [ ! -f ${PREFIX}/etc/shorewall6-lite/shorewall6-lite.conf ]; then
|
|
|
|
run_install $OWNERSHIP -m 0744 shorewall6-lite.conf ${PREFIX}/etc/shorewall6-lite/shorewall6-lite.conf
|
|
|
|
echo "Config file installed as ${PREFIX}/etc/shorewall6-lite/shorewall6-lite.conf"
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$ARCHLINUX" ] ; then
|
2008-12-10 01:33:55 +01:00
|
|
|
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${PREFIX}/etc/shorewall6-lite/shorewall.conf
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Makefile
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
run_install $OWNERSHIP -m 0600 Makefile ${PREFIX}/etc/shorewall6-lite/Makefile
|
|
|
|
echo "Makefile installed as ${PREFIX}/etc/shorewall6-lite/Makefile"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the default config path file
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
install_file configpath ${PREFIX}/usr/share/shorewall6-lite/configpath 0644
|
|
|
|
echo "Default config path file installed as ${PREFIX}/usr/share/shorewall6-lite/configpath"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the libraries
|
|
|
|
#
|
|
|
|
for f in lib.* ; do
|
|
|
|
if [ -f $f ]; then
|
2008-12-10 01:33:55 +01:00
|
|
|
install_file $f ${PREFIX}/usr/share/shorewall6-lite/$f 0644
|
|
|
|
echo "Library ${f#*.} file installed as ${PREFIX}/usr/share/shorewall6-lite/$f"
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
ln -sf lib.base ${PREFIX}/usr/share/shorewall6-lite/functions
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "Common functions linked through ${PREFIX}/usr/share/shorewall6-lite/functions"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install Shorecap
|
|
|
|
#
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
install_file shorecap ${PREFIX}/usr/share/shorewall6-lite/shorecap 0755
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
echo
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "Capability file builder installed in ${PREFIX}/usr/share/shorewall6-lite/shorecap"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install wait4ifup
|
|
|
|
#
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
install_file wait4ifup ${PREFIX}/usr/share/shorewall6-lite/wait4ifup 0755
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
echo
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "wait4ifup installed in ${PREFIX}/usr/share/shorewall6-lite/wait4ifup"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Modules file
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
run_install $OWNERSHIP -m 0600 modules ${PREFIX}/usr/share/shorewall6-lite/modules
|
|
|
|
echo "Modules file installed as ${PREFIX}/usr/share/shorewall6-lite/modules"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Man Pages
|
|
|
|
#
|
|
|
|
|
2008-12-14 19:08:56 +01:00
|
|
|
cd manpages
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-14 19:08:56 +01:00
|
|
|
for f in *.5; do
|
|
|
|
gzip -c $f > $f.gz
|
|
|
|
run_install -D -m 644 $f.gz ${PREFIX}/usr/share/man/man5/$f.gz
|
2009-03-25 16:51:03 +01:00
|
|
|
echo "Man page $f.gz installed to ${PREFIX}/usr/share/man/man5/$f.gz"
|
2008-12-14 19:08:56 +01:00
|
|
|
done
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-14 19:08:56 +01:00
|
|
|
for f in *.8; do
|
|
|
|
gzip -c $f > $f.gz
|
|
|
|
run_install -D -m 644 $f.gz ${PREFIX}/usr/share/man/man8/$f.gz
|
2009-03-25 16:51:03 +01:00
|
|
|
echo "Man page $f.gz installed to ${PREFIX}/usr/share/man/man8/$f.gz"
|
2008-12-14 19:08:56 +01:00
|
|
|
done
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-14 19:08:56 +01:00
|
|
|
cd ..
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2008-12-14 19:08:56 +01:00
|
|
|
echo "Man Pages Installed"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create the version file
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "$VERSION" > ${PREFIX}/usr/share/shorewall6-lite/version
|
|
|
|
chmod 644 ${PREFIX}/usr/share/shorewall6-lite/version
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# Remove and create the symbolic link to the init script
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ -z "$PREFIX" ]; then
|
2008-12-10 01:33:55 +01:00
|
|
|
rm -f /usr/share/shorewall6-lite/init
|
|
|
|
ln -s ${DEST}/${INIT} /usr/share/shorewall6-lite/init
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PREFIX" -a -n "$first_install" ]; then
|
|
|
|
if [ -n "$DEBIAN" ]; then
|
2008-12-10 01:33:55 +01:00
|
|
|
run_install $OWNERSHIP -m 0644 default.debian /etc/default/shorewall6-lite
|
|
|
|
ln -s ../init.d/shorewall6-lite /etc/rcS.d/S40shorewall6-lite
|
|
|
|
echo "Shorewall6 Lite will start automatically at boot"
|
2008-12-09 17:50:17 +01:00
|
|
|
touch /var/log/shorewall-init.log
|
|
|
|
else
|
|
|
|
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
|
2008-12-10 01:33:55 +01:00
|
|
|
if insserv /etc/init.d/shorewall6-lite ; then
|
|
|
|
echo "Shorewall6 Lite will start automatically at boot"
|
2008-12-09 17:50:17 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
|
2008-12-10 01:33:55 +01:00
|
|
|
if chkconfig --add shorewall6-lite ; then
|
|
|
|
echo "Shorewall6 Lite will start automatically in run levels as follows:"
|
|
|
|
chkconfig --list shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ -x /sbin/rc-update ]; then
|
2008-12-10 01:33:55 +01:00
|
|
|
if rc-update add shorewall6-lite default; then
|
|
|
|
echo "Shorewall6 Lite will start automatically at boot"
|
2008-12-09 17:50:17 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ "$INIT" != rc.firewall ]; then #Slackware starts this automatically
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Report Success
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "shorewall6 Lite Version $VERSION Installed"
|