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]
|
|
|
|
#
|
2010-01-01 22:27:48 +01:00
|
|
|
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2011-02-06 01:41:34 +01:00
|
|
|
VERSION=4.4.18-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"
|
|
|
|
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
|
|
|
|
{
|
2010-05-29 19:50:39 +02:00
|
|
|
run_install $T $OWNERSHIP -m $3 $1 ${2}
|
2008-12-09 17:50:17 +01:00
|
|
|
}
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
[ -n "$DESTDIR" ] || DESTDIR="$PREFIX"
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# Parse the run line
|
|
|
|
#
|
|
|
|
# DEST is the SysVInit script directory
|
|
|
|
# INIT is the name of the script in the $DEST directory
|
|
|
|
# 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
|
|
|
|
|
|
|
|
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
|
|
|
|
#
|
2010-05-09 01:32:03 +02:00
|
|
|
INSTALLD='-D'
|
2010-05-29 19:50:39 +02:00
|
|
|
T='-T'
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2009-07-25 16:30:08 +02:00
|
|
|
case $(uname) in
|
|
|
|
CYGWIN*)
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" ]; then
|
2009-07-25 16:44:53 +02:00
|
|
|
DEST=
|
|
|
|
INIT=
|
|
|
|
fi
|
|
|
|
|
2009-07-25 16:30:08 +02:00
|
|
|
OWNER=$(id -un)
|
|
|
|
GROUP=$(id -gn)
|
|
|
|
;;
|
2010-05-09 01:32:03 +02:00
|
|
|
Darwin)
|
2010-05-29 19:57:27 +02:00
|
|
|
INSTALLD=
|
2010-05-29 19:50:39 +02:00
|
|
|
T=
|
2010-05-09 01:32:03 +02:00
|
|
|
;;
|
2009-07-25 16:30:08 +02:00
|
|
|
*)
|
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=root
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
OWNERSHIP="-o $OWNER -g $GROUP"
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "$DESTDIR" ]; then
|
2009-07-25 16:30:08 +02:00
|
|
|
if [ `id -u` != 0 ] ; then
|
|
|
|
echo "Not setting file owner/group permissions, not running as root."
|
|
|
|
OWNERSHIP=""
|
|
|
|
fi
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
install -d $OWNERSHIP -m 755 ${DESTDIR}/sbin
|
|
|
|
install -d $OWNERSHIP -m 755 ${DESTDIR}${DEST}
|
2008-12-09 17:50:17 +01:00
|
|
|
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
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" -a -d /etc/shorewall6-lite ]; then
|
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
|
2010-06-01 15:42:11 +02:00
|
|
|
rm -rf ${DESTDIR}/etc/shorewall6-lite
|
|
|
|
rm -rf ${DESTDIR}/usr/share/shorewall6-lite
|
|
|
|
rm -rf ${DESTDIR}/var/lib/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
2010-04-07 22:17:11 +02:00
|
|
|
#
|
|
|
|
# Check for /sbin/shorewall6-lite
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -f ${DESTDIR}/sbin/shorewall6-lite ]; then
|
2010-04-07 22:16:16 +02:00
|
|
|
first_install=""
|
|
|
|
else
|
|
|
|
first_install="Yes"
|
|
|
|
fi
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
delete_file ${DESTDIR}/usr/share/shorewall6-lite/xmodules
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file shorewall6-lite ${DESTDIR}/sbin/shorewall6-lite 0544
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
echo "Shorewall6 Lite control program installed in ${DESTDIR}/sbin/shorewall6-lite"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Firewall Script
|
|
|
|
#
|
|
|
|
if [ -n "$DEBIAN" ]; then
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file init.debian.sh ${DESTDIR}/etc/init.d/shorewall6-lite 0544
|
2008-12-09 17:50:17 +01:00
|
|
|
elif [ -n "$ARCHLINUX" ]; then
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file init.archlinux.sh ${DESTDIR}${DEST}/$INIT 0544
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
else
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file init.sh ${DESTDIR}${DEST}/$INIT 0544
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
echo "Shorewall6 Lite script installed in ${DESTDIR}${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
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
mkdir -p ${DESTDIR}/etc/shorewall6-lite
|
|
|
|
mkdir -p ${DESTDIR}/usr/share/shorewall6-lite
|
|
|
|
mkdir -p ${DESTDIR}/var/lib/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
chmod 755 ${DESTDIR}/etc/shorewall6-lite
|
|
|
|
chmod 755 ${DESTDIR}/usr/share/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "$DESTDIR" ]; then
|
|
|
|
mkdir -p ${DESTDIR}/etc/logrotate.d
|
|
|
|
chmod 755 ${DESTDIR}/etc/logrotate.d
|
2009-11-03 19:06:10 +01:00
|
|
|
fi
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# Install the config file
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ ! -f ${DESTDIR}/etc/shorewall6-lite/shorewall6-lite.conf ]; then
|
|
|
|
install_file shorewall6-lite.conf ${DESTDIR}/etc/shorewall6-lite/shorewall6-lite.conf 0744
|
|
|
|
echo "Config file installed as ${DESTDIR}/etc/shorewall6-lite/shorewall6-lite.conf"
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$ARCHLINUX" ] ; then
|
2010-06-01 15:42:11 +02:00
|
|
|
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${DESTDIR}/etc/shorewall6-lite/shorewall.conf
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Makefile
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
run_install $OWNERSHIP -m 0600 Makefile ${DESTDIR}/etc/shorewall6-lite
|
|
|
|
echo "Makefile installed as ${DESTDIR}/etc/shorewall6-lite/Makefile"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the default config path file
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file configpath ${DESTDIR}/usr/share/shorewall6-lite/configpath 0644
|
|
|
|
echo "Default config path file installed as ${DESTDIR}/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
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file $f ${DESTDIR}/usr/share/shorewall6-lite/$f 0644
|
|
|
|
echo "Library ${f#*.} file installed as ${DESTDIR}/usr/share/shorewall6-lite/$f"
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
ln -sf lib.base ${DESTDIR}/usr/share/shorewall6-lite/functions
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
echo "Common functions linked through ${DESTDIR}/usr/share/shorewall6-lite/functions"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install Shorecap
|
|
|
|
#
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file shorecap ${DESTDIR}/usr/share/shorewall6-lite/shorecap 0755
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
echo
|
2010-06-01 15:42:11 +02:00
|
|
|
echo "Capability file builder installed in ${DESTDIR}/usr/share/shorewall6-lite/shorecap"
|
2008-12-09 17:50:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install wait4ifup
|
|
|
|
#
|
|
|
|
|
2010-05-24 15:50:47 +02:00
|
|
|
if [ -f wait4ifup ]; then
|
2010-06-01 15:42:11 +02:00
|
|
|
install_file wait4ifup ${DESTDIR}/usr/share/shorewall6-lite/wait4ifup 0755
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
echo
|
2010-06-01 15:42:11 +02:00
|
|
|
echo "wait4ifup installed in ${DESTDIR}/usr/share/shorewall6-lite/wait4ifup"
|
2010-05-24 01:36:23 +02:00
|
|
|
fi
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
if [ -f modules ]; then
|
|
|
|
#
|
|
|
|
# Install the Modules file
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
run_install $OWNERSHIP -m 0600 modules ${DESTDIR}/usr/share/shorewall6-lite
|
|
|
|
echo "Modules file installed as ${DESTDIR}/usr/share/shorewall6-lite/modules"
|
2010-05-24 01:36:23 +02:00
|
|
|
fi
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
if [ -d manpages ]; then
|
|
|
|
#
|
|
|
|
# Install the Man Pages
|
|
|
|
#
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
cd manpages
|
2010-05-09 01:32:03 +02:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}/usr/share/man/man5/ ${DESTDIR}/usr/share/man/man8/
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
for f in *.5; do
|
|
|
|
gzip -c $f > $f.gz
|
2010-06-01 15:42:11 +02:00
|
|
|
run_install $INSTALLD -m 644 $f.gz ${DESTDIR}/usr/share/man/man5/$f.gz
|
|
|
|
echo "Man page $f.gz installed to ${DESTDIR}/usr/share/man/man5/$f.gz"
|
2010-05-24 01:36:23 +02:00
|
|
|
done
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
for f in *.8; do
|
|
|
|
gzip -c $f > $f.gz
|
2010-06-01 15:42:11 +02:00
|
|
|
run_install $INSTALLD -m 644 $f.gz ${DESTDIR}/usr/share/man/man8/$f.gz
|
|
|
|
echo "Man page $f.gz installed to ${DESTDIR}/usr/share/man/man8/$f.gz"
|
2010-05-24 01:36:23 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
cd ..
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-05-24 01:36:23 +02:00
|
|
|
echo "Man Pages Installed"
|
|
|
|
fi
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -d ${DESTDIR}/etc/logrotate.d ]; then
|
|
|
|
run_install $OWNERSHIP -m 0644 logrotate ${DESTDIR}/etc/logrotate.d/shorewall6-lite
|
|
|
|
echo "Logrotate file installed as ${DESTDIR}/etc/logrotate.d/shorewall6-lite"
|
2009-11-03 19:06:10 +01:00
|
|
|
fi
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# Create the version file
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
echo "$VERSION" > ${DESTDIR}/usr/share/shorewall6-lite/version
|
|
|
|
chmod 644 ${DESTDIR}/usr/share/shorewall6-lite/version
|
2008-12-09 17:50:17 +01:00
|
|
|
#
|
|
|
|
# Remove and create the symbolic link to the init script
|
|
|
|
#
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" ]; 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
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" ]; then
|
2010-04-10 20:46:50 +02:00
|
|
|
touch /var/log/shorewall6-lite-init.log
|
|
|
|
|
|
|
|
if [ -n "$first_install" ]; then
|
|
|
|
if [ -n "$DEBIAN" ]; then
|
|
|
|
run_install $OWNERSHIP -m 0644 default.debian /etc/default/shorewall6-lite
|
2010-06-25 20:14:55 +02:00
|
|
|
|
2010-10-13 17:42:35 +02:00
|
|
|
update-rc.d shorewall6-lite defaults
|
2010-06-25 20:14:55 +02:00
|
|
|
|
2010-04-10 20:46:50 +02:00
|
|
|
echo "Shorewall6 Lite will start automatically at boot"
|
|
|
|
else
|
|
|
|
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
|
|
|
|
if insserv /etc/init.d/shorewall6-lite ; then
|
|
|
|
echo "Shorewall6 Lite will start automatically at boot"
|
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
|
|
|
|
if chkconfig --add shorewall6-lite ; then
|
|
|
|
echo "Shorewall6 Lite will start automatically in run levels as follows:"
|
|
|
|
chkconfig --list shorewall6-lite
|
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ -x /sbin/rc-update ]; then
|
|
|
|
if rc-update add shorewall6-lite default; then
|
|
|
|
echo "Shorewall6 Lite will start automatically at boot"
|
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif [ "$INIT" != rc.firewall ]; then #Slackware starts this automatically
|
2008-12-09 17:50:17 +01:00
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Report Success
|
|
|
|
#
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "shorewall6 Lite Version $VERSION Installed"
|