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.
|
|
|
|
#
|
|
|
|
|
2010-01-16 00:42:38 +01:00
|
|
|
VERSION=4.4.6.1
|
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
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
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=
|
|
|
|
|
2009-07-25 16:30:08 +02:00
|
|
|
case $(uname) in
|
|
|
|
CYGWIN*)
|
2009-07-25 16:44:53 +02:00
|
|
|
if [ -z "$PREFIX" ]; then
|
|
|
|
DEST=
|
|
|
|
INIT=
|
|
|
|
fi
|
|
|
|
|
2009-07-25 16:30:08 +02:00
|
|
|
OWNER=$(id -un)
|
|
|
|
GROUP=$(id -gn)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=root
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
OWNERSHIP="-o $OWNER -g $GROUP"
|
|
|
|
|
|
|
|
if [ -n "$PREFIX" ]; 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
|
|
|
|
|
|
|
|
install -d $OWNERSHIP -m 755 ${PREFIX}/sbin
|
|
|
|
install -d $OWNERSHIP -m 755 ${PREFIX}${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
|
|
|
#
|
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
|
|
|
|
2009-11-03 19:06:10 +01:00
|
|
|
if [ -n "$PREFIX" ]; then
|
|
|
|
mkdir -p ${PREFIX}/etc/logrotate.d
|
|
|
|
chmod 755 ${PREFIX}/etc/logrotate.d
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
2009-11-03 19:06:10 +01:00
|
|
|
if [ -d ${PREFIX}/etc/logrotate.d ]; then
|
|
|
|
run_install $OWNERSHIP -m 0644 logrotate ${PREFIX}/etc/logrotate.d/shorewall6-lite
|
|
|
|
echo "Logrotate file installed as ${PREFIX}/etc/logrotate.d/shorewall6-lite"
|
|
|
|
fi
|
|
|
|
|
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"
|