2010-05-17 00:35:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Script to install Shoreline Firewall Init
|
|
|
|
#
|
2016-02-29 20:03:09 +01:00
|
|
|
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
|
2010-05-23 23:10:50 +02:00
|
|
|
# (c) 2010 - Roberto C. Sanchez (roberto@connexer.com)
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
2020-03-26 22:58:35 +01:00
|
|
|
# Shorewall documentation is available at https://shorewall.org
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
2014-01-04 18:48:27 +01:00
|
|
|
# This program is part of Shorewall.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by the
|
|
|
|
# Free Software Foundation, either version 2 of the license or, at your
|
|
|
|
# option, any later version.
|
|
|
|
#
|
|
|
|
# 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.
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
2014-01-04 18:48:27 +01:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2017-02-20 18:51:59 +01:00
|
|
|
VERSION=xxx # The Build script inserts the actual version
|
2016-01-05 00:45:21 +01:00
|
|
|
PRODUCT=shorewall-init
|
|
|
|
Product="Shorewall Init"
|
2010-05-17 00:35:22 +02:00
|
|
|
|
|
|
|
usage() # $1 = exit status
|
|
|
|
{
|
|
|
|
ME=$(basename $0)
|
2017-02-20 18:51:59 +01:00
|
|
|
echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
|
|
|
|
echo "where <option> is one of"
|
|
|
|
echo " -h"
|
|
|
|
echo " -v"
|
|
|
|
echo " -n"
|
2010-05-17 00:35:22 +02:00
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
2016-01-05 00:45:21 +01:00
|
|
|
install_file() # $1 = source $2 = target $3 = mode
|
2010-05-17 00:35:22 +02:00
|
|
|
{
|
2016-01-05 00:45:21 +01:00
|
|
|
if cp -f $1 $2; then
|
|
|
|
if chmod $3 $2; then
|
|
|
|
if [ -n "$OWNER" ]; then
|
|
|
|
if chown $OWNER:$GROUP $2; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "ERROR: Failed to install $2" >&2
|
|
|
|
exit 1
|
2010-05-17 00:35:22 +02:00
|
|
|
}
|
|
|
|
|
2016-01-05 00:45:21 +01:00
|
|
|
#
|
|
|
|
# Change to the directory containing this script
|
|
|
|
#
|
|
|
|
cd "$(dirname $0)"
|
2012-03-24 21:05:39 +01:00
|
|
|
|
2017-02-20 18:51:49 +01:00
|
|
|
#
|
|
|
|
# Source common functions
|
|
|
|
#
|
|
|
|
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
|
|
|
|
|
2012-02-23 19:07:02 +01:00
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
# Parse the run line
|
2012-02-23 19:07:02 +01:00
|
|
|
#
|
2013-09-09 18:49:32 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
finished=0
|
2014-10-03 16:59:41 +02:00
|
|
|
configure=1
|
2010-06-01 15:42:11 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
while [ $finished -eq 0 ] ; do
|
2014-10-04 02:07:03 +02:00
|
|
|
option="$1"
|
|
|
|
|
|
|
|
case "$option" in
|
2012-03-24 21:05:39 +01:00
|
|
|
-*)
|
|
|
|
option=${option#-}
|
|
|
|
|
|
|
|
while [ -n "$option" ]; do
|
|
|
|
case $option in
|
|
|
|
h)
|
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
v)
|
2017-02-20 18:51:46 +01:00
|
|
|
echo "$Product Firewall Installer Version $VERSION"
|
2012-03-24 21:05:39 +01:00
|
|
|
exit 0
|
|
|
|
;;
|
2014-10-03 16:59:41 +02:00
|
|
|
n*)
|
|
|
|
configure=0
|
|
|
|
option=${option#n}
|
|
|
|
;;
|
2012-03-24 21:05:39 +01:00
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift
|
2010-05-17 00:35:22 +02:00
|
|
|
;;
|
|
|
|
*)
|
2012-03-24 21:05:39 +01:00
|
|
|
finished=1
|
2010-05-17 00:35:22 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
#
|
|
|
|
# Read the RC file
|
|
|
|
#
|
|
|
|
if [ $# -eq 0 ]; then
|
2012-04-01 02:40:18 +02:00
|
|
|
if [ -f ./shorewallrc ]; then
|
2016-12-19 19:25:30 +01:00
|
|
|
file=./shorewallrc
|
2017-02-20 18:51:58 +01:00
|
|
|
. $file || fatal_error "Can not load the RC file: $file"
|
2012-04-01 02:40:18 +02:00
|
|
|
elif [ -f ~/.shorewallrc ]; then
|
2016-12-19 19:25:30 +01:00
|
|
|
file=~/.shorewallrc
|
2017-02-20 18:51:58 +01:00
|
|
|
. $file || fatal_error "Can not load the RC file: $file"
|
|
|
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
|
|
|
file=/usr/share/shorewall/shorewallrc
|
|
|
|
. $file || fatal_error "Can not load the RC file: $file"
|
|
|
|
else
|
|
|
|
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
|
2012-03-24 21:05:39 +01:00
|
|
|
fi
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
file=$1
|
|
|
|
case $file in
|
|
|
|
/*|.*)
|
|
|
|
;;
|
|
|
|
*)
|
2017-02-20 18:51:58 +01:00
|
|
|
file=./$file || exit 1
|
2012-03-24 21:05:39 +01:00
|
|
|
;;
|
|
|
|
esac
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2017-02-20 18:51:58 +01:00
|
|
|
. $file || fatal_error "Can not load the RC file: $file"
|
2012-03-24 21:05:39 +01:00
|
|
|
else
|
|
|
|
usage 1
|
|
|
|
fi
|
2011-05-14 14:31:19 +02:00
|
|
|
|
2012-09-02 23:36:11 +02:00
|
|
|
if [ -z "${VARLIB}" ]; then
|
|
|
|
VARLIB=${VARDIR}
|
2012-09-10 20:12:43 +02:00
|
|
|
VARDIR=${VARLIB}/${PRODUCT}
|
2012-09-03 00:51:35 +02:00
|
|
|
elif [ -z "${VARDIR}" ]; then
|
2012-09-10 20:12:43 +02:00
|
|
|
VARDIR=${VARLIB}/${PRODUCT}
|
2012-09-02 23:36:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
for var in SHAREDIR LIBEXECDIR CONFDIR SBINDIR VARLIB VARDIR; do
|
2012-03-24 21:05:39 +01:00
|
|
|
require $var
|
|
|
|
done
|
2011-05-14 14:31:19 +02:00
|
|
|
|
2014-10-04 16:50:30 +02:00
|
|
|
[ -n "$SANDBOX" ] && configure=0
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
2012-02-21 21:34:41 +01:00
|
|
|
|
2015-03-24 15:51:56 +01:00
|
|
|
[ $configure -eq 1 ] && ETC=/etc || ETC="${CONFDIR}"
|
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
if [ -z "$BUILD" ]; then
|
2012-02-17 22:22:06 +01:00
|
|
|
case $(uname) in
|
2012-02-22 22:32:10 +01:00
|
|
|
cygwin*)
|
|
|
|
BUILD=cygwin
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
|
|
|
Darwin)
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=apple
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
|
|
|
*)
|
2013-08-09 02:44:40 +02:00
|
|
|
if [ -f /etc/os-release ]; then
|
2013-10-25 16:08:21 +02:00
|
|
|
eval $(cat /etc/os-release | grep ^ID=)
|
2013-08-09 02:44:40 +02:00
|
|
|
|
|
|
|
case $ID in
|
2014-09-23 12:18:58 +02:00
|
|
|
fedora|rhel|centos|foobar)
|
2013-08-09 02:44:40 +02:00
|
|
|
BUILD=redhat
|
|
|
|
;;
|
2013-10-25 16:08:21 +02:00
|
|
|
debian|ubuntu)
|
2013-08-09 02:44:40 +02:00
|
|
|
BUILD=debian
|
|
|
|
;;
|
|
|
|
opensuse)
|
|
|
|
BUILD=suse
|
|
|
|
;;
|
2018-05-29 17:13:26 +02:00
|
|
|
alt|basealt|altlinux)
|
|
|
|
BUILD=alt
|
|
|
|
;;
|
2013-08-09 02:44:40 +02:00
|
|
|
*)
|
|
|
|
BUILD="$ID"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
elif [ -f /etc/debian_version ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=debian
|
2013-10-25 16:08:21 +02:00
|
|
|
elif [ -f /etc/ubuntu_version ]; then
|
|
|
|
BUILD=debian
|
2013-09-17 17:22:52 +02:00
|
|
|
elif [ -f /etc/gentoo-release ]; then
|
|
|
|
BUILD=gentoo
|
2018-05-29 17:13:26 +02:00
|
|
|
elif [ -f /etc/altlinux-release ]; then
|
|
|
|
BUILD=alt
|
2012-02-17 22:22:06 +01:00
|
|
|
elif [ -f /etc/redhat-release ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=redhat
|
2012-02-18 00:26:02 +01:00
|
|
|
elif [ -f /etc/SuSE-release ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=suse
|
2012-02-17 22:22:06 +01:00
|
|
|
elif [ -f /etc/slackware-version ] ; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=slackware
|
2012-02-17 22:22:06 +01:00
|
|
|
elif [ -f /etc/arch-release ] ; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=archlinux
|
2015-12-28 01:47:31 +01:00
|
|
|
elif [ -f ${CONFDIR}/openwrt_release ]; then
|
|
|
|
BUILD=openwrt
|
2012-02-17 22:22:06 +01:00
|
|
|
else
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=linux
|
2012-02-17 22:22:06 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
case $BUILD in
|
|
|
|
apple)
|
2016-01-05 00:45:21 +01:00
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=wheel
|
2012-02-22 22:32:10 +01:00
|
|
|
;;
|
2016-01-05 00:45:21 +01:00
|
|
|
cygwin*|CYGWIN*)
|
|
|
|
OWNER=$(id -un)
|
|
|
|
GROUP=$(id -gn)
|
|
|
|
;;
|
2010-05-17 00:35:22 +02:00
|
|
|
*)
|
2016-01-05 00:45:21 +01:00
|
|
|
if [ $(id -u) -eq 0 ]; then
|
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=root
|
|
|
|
fi
|
2010-05-17 00:35:22 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-01-05 00:45:21 +01:00
|
|
|
[ -n "$OWNER" ] && OWNERSHIP="$OWNER:$GROUP"
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
[ -n "$HOST" ] || HOST=$BUILD
|
2012-02-17 22:22:06 +01:00
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
case "$HOST" in
|
|
|
|
debian)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Installing Debian-specific configuration..."
|
|
|
|
;;
|
2013-09-17 17:22:52 +02:00
|
|
|
gentoo)
|
|
|
|
echo "Installing Gentoo-specific configuration..."
|
|
|
|
;;
|
2013-08-09 02:44:40 +02:00
|
|
|
redhat)
|
2012-02-21 01:11:28 +01:00
|
|
|
echo "Installing Redhat/Fedora-specific configuration..."
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
slackware)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Shorewall-init is currently not supported on Slackware" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
archlinux)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Shorewall-init is currently not supported on Arch Linux" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2013-08-09 02:44:40 +02:00
|
|
|
suse)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Installing SuSE-specific configuration..."
|
|
|
|
;;
|
2015-12-28 01:47:31 +01:00
|
|
|
openwrt)
|
2016-01-05 00:45:21 +01:00
|
|
|
echo "Installing Openwrt-specific configuration..."
|
2015-12-28 01:47:31 +01:00
|
|
|
;;
|
2018-05-29 17:13:26 +02:00
|
|
|
alt)
|
|
|
|
echo "Installing ALT-specific configuration...";
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
linux)
|
2017-02-20 18:52:03 +01:00
|
|
|
fatal_error "Shorewall-init is not supported on this system"
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
|
|
|
*)
|
2017-02-20 18:52:03 +01:00
|
|
|
fatal_error "Unsupported HOST distribution: \"$HOST\""
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-02-29 17:39:27 +01:00
|
|
|
[ -z "$TARGET" ] && TARGET=$HOST
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "$DESTDIR" ]; then
|
2016-01-05 00:45:21 +01:00
|
|
|
if [ $(id -u) != 0 ] ; then
|
2010-05-17 00:35:22 +02:00
|
|
|
echo "Not setting file owner/group permissions, not running as root."
|
|
|
|
OWNERSHIP=""
|
|
|
|
fi
|
|
|
|
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${INITDIR} 0755
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2017-02-20 18:51:46 +01:00
|
|
|
echo "Installing $Product Version $VERSION"
|
2010-05-17 00:35:22 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check for /usr/share/shorewall-init/version
|
|
|
|
#
|
2017-02-20 18:51:46 +01:00
|
|
|
if [ -f ${DESTDIR}${SHAREDIR}/$PRODUCT/version ]; then
|
2010-05-17 00:35:22 +02:00
|
|
|
first_install=""
|
|
|
|
else
|
|
|
|
first_install="Yes"
|
|
|
|
fi
|
|
|
|
|
2017-02-20 18:51:54 +01:00
|
|
|
[ -n "$DESTDIR" ] && make_parent_directory ${DESTDIR}${CONFDIR}/logrotate.d 0755
|
2012-06-02 17:26:06 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
#
|
|
|
|
# Install the Firewall Script
|
|
|
|
#
|
2012-02-23 19:59:10 +01:00
|
|
|
if [ -n "$INITFILE" ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${INITDIR} 0755
|
2012-03-24 21:05:39 +01:00
|
|
|
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
|
2012-04-01 19:47:24 +02:00
|
|
|
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE
|
2012-03-24 21:05:39 +01:00
|
|
|
|
|
|
|
if [ -n "${AUXINITSOURCE}" ]; then
|
|
|
|
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$AUXINITFILE 0544
|
|
|
|
fi
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2013-09-09 17:11:45 +02:00
|
|
|
echo "SysV init script $INITSOURCE installed in ${DESTDIR}${INITDIR}/$INITFILE"
|
2012-02-23 19:59:10 +01:00
|
|
|
fi
|
2012-03-24 21:05:39 +01:00
|
|
|
|
2011-08-23 23:07:44 +02:00
|
|
|
#
|
|
|
|
# Install the .service file
|
|
|
|
#
|
2014-10-13 20:56:26 +02:00
|
|
|
if [ -z "${SERVICEDIR}" ]; then
|
|
|
|
SERVICEDIR="$SYSTEMD"
|
2014-10-08 01:46:16 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-13 20:56:26 +02:00
|
|
|
if [ -n "$SERVICEDIR" ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${SERVICEDIR} 0755
|
2013-08-18 23:27:26 +02:00
|
|
|
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
2016-01-05 00:45:21 +01:00
|
|
|
install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 0644
|
2014-10-13 20:56:26 +02:00
|
|
|
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
|
|
|
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
|
2017-02-20 18:51:54 +01:00
|
|
|
[ -n "$DESTDIR" -o $configure -eq 0 ] && make_parent_directory ${DESTDIR}${SBINDIR} 0755
|
2017-02-20 18:51:46 +01:00
|
|
|
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0700
|
|
|
|
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/$PRODUCT
|
|
|
|
echo "CLI installed as ${DESTDIR}${SBINDIR}/$PRODUCT"
|
2011-08-23 23:07:44 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
|
|
|
# Create /usr/share/shorewall-init if needed
|
|
|
|
#
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${SHAREDIR}/$PRODUCT 0755
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2012-06-02 17:26:06 +02:00
|
|
|
#
|
|
|
|
# Install logrotate file
|
|
|
|
#
|
|
|
|
if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then
|
2016-01-05 00:45:21 +01:00
|
|
|
install_file logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT 0644
|
2012-06-02 17:26:06 +02:00
|
|
|
echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT"
|
|
|
|
fi
|
|
|
|
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
|
|
|
# Create the version file
|
|
|
|
#
|
2017-02-20 18:51:46 +01:00
|
|
|
echo "$VERSION" > ${DESTDIR}/${SHAREDIR}/$PRODUCT/version
|
|
|
|
chmod 0644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version
|
2010-05-17 00:35:22 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Remove and create the symbolic link to the init script
|
|
|
|
#
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" ]; then
|
2017-02-20 18:51:46 +01:00
|
|
|
rm -f ${SHAREDIR}/$PRODUCT/init
|
|
|
|
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
if [ $HOST = debian ]; then
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "${DESTDIR}" ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${ETC}/network/if-up.d 0755
|
2020-04-20 00:19:13 +02:00
|
|
|
make_parent_directory ${DESTDIR}${ETC}/network/if-down.d 0755
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${ETC}/network/if-post-down.d 0755
|
2014-10-04 18:00:12 +02:00
|
|
|
elif [ $configure -eq 0 ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${CONFDIR}/network/if-up.d 0755
|
2020-04-20 00:19:13 +02:00
|
|
|
make_parent_directory ${DESTDIR}${CONFDIR}/network/if-down.d 0755
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${CONFDIR}/network/if-post-down.d 0755
|
2010-05-24 00:34:42 +02:00
|
|
|
fi
|
|
|
|
|
2017-02-20 18:51:46 +01:00
|
|
|
if [ ! -f ${DESTDIR}${CONFDIR}/default/$PRODUCT ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
[ -n "${DESTDIR}" ] && make_parent_directory ${DESTDIR}${ETC}/default 0755
|
2010-05-24 00:34:42 +02:00
|
|
|
|
2017-02-20 18:51:54 +01:00
|
|
|
[ $configure -eq 1 ] || make_parent_directory ${DESTDIR}${CONFDIR}/default 0755
|
2017-03-03 15:25:55 +01:00
|
|
|
install_file ${SYSCONFFILE} ${DESTDIR}${ETC}/default/$PRODUCT 0644
|
|
|
|
echo "${SYSCONFFILE} file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
|
2010-05-19 00:30:53 +02:00
|
|
|
fi
|
2013-03-15 21:03:53 +01:00
|
|
|
|
|
|
|
IFUPDOWN=ifupdown.debian.sh
|
2010-05-19 00:30:53 +02:00
|
|
|
else
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "$DESTDIR" ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${SYSCONFDIR} 0755
|
2010-05-24 00:34:42 +02:00
|
|
|
|
2010-05-27 15:49:49 +02:00
|
|
|
if [ -z "$RPM" ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
if [ $HOST = suse ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${ETC}/sysconfig/network/if-up.d 0755
|
|
|
|
make_parent_directory ${DESTDIR}${ETC}/sysconfig/network/if-down.d 0755
|
2013-09-17 17:22:52 +02:00
|
|
|
elif [ $HOST = gentoo ]; then
|
|
|
|
# Gentoo does not support if-{up,down}.d
|
2013-10-03 23:06:08 +02:00
|
|
|
/bin/true
|
2016-01-05 00:45:21 +01:00
|
|
|
elif [ $HOST = openwrt ]; then
|
2017-02-20 18:51:59 +01:00
|
|
|
# Not implemented on OpenWRT
|
2016-01-05 00:45:21 +01:00
|
|
|
/bin/true
|
2010-05-27 15:49:49 +02:00
|
|
|
else
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d 0755
|
2010-05-27 15:49:49 +02:00
|
|
|
fi
|
2010-05-24 00:34:42 +02:00
|
|
|
fi
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2013-09-10 17:04:15 +02:00
|
|
|
if [ -n "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then
|
2016-01-05 00:45:21 +01:00
|
|
|
install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/$PRODUCT 0644
|
|
|
|
echo "${SYSCONFFILE} file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
|
2013-09-10 17:04:15 +02:00
|
|
|
fi
|
2013-03-15 18:25:32 +01:00
|
|
|
|
|
|
|
[ $HOST = suse ] && IFUPDOWN=ifupdown.suse.sh || IFUPDOWN=ifupdown.fedora.sh
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-23 21:53:56 +02:00
|
|
|
#
|
|
|
|
# Install the ifupdown script
|
|
|
|
#
|
2010-05-24 00:34:42 +02:00
|
|
|
|
2016-01-05 00:45:21 +01:00
|
|
|
if [ $HOST != openwrt ]; then
|
|
|
|
cp $IFUPDOWN ifupdown
|
2012-03-31 23:42:01 +02:00
|
|
|
|
2016-01-05 00:45:21 +01:00
|
|
|
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ifupdown
|
2012-03-31 23:42:01 +02:00
|
|
|
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${LIBEXECDIR}/$PRODUCT 0755
|
2010-05-27 01:45:09 +02:00
|
|
|
|
2017-02-20 18:51:46 +01:00
|
|
|
install_file ifupdown ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown 0544
|
2016-01-05 00:45:21 +01:00
|
|
|
fi
|
2010-05-23 21:53:56 +02:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -d ${DESTDIR}/etc/NetworkManager ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
[ $configure -eq 1 ] || make_parent_directory ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d 0755
|
2015-03-24 15:51:56 +01:00
|
|
|
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544
|
2010-05-23 21:53:56 +02:00
|
|
|
fi
|
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
case $HOST in
|
|
|
|
debian)
|
2014-10-04 18:00:12 +02:00
|
|
|
if [ $configure -eq 1 ]; then
|
|
|
|
install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544
|
2020-04-20 00:19:13 +02:00
|
|
|
install_file ifupdown ${DESTDIR}/etc/network/if-down.d/shorewall 0544
|
2014-10-04 18:00:12 +02:00
|
|
|
install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
|
|
|
|
else
|
2014-10-06 01:52:59 +02:00
|
|
|
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-up.d/shorewall 0544
|
2020-04-20 00:19:13 +02:00
|
|
|
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-down.d/shorewall 0544
|
2014-10-06 01:52:59 +02:00
|
|
|
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-post-down.d/shorewall 0544
|
2014-10-04 18:00:12 +02:00
|
|
|
fi
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
suse)
|
2012-02-17 22:22:06 +01:00
|
|
|
if [ -z "$RPM" ]; then
|
2014-10-04 18:00:12 +02:00
|
|
|
if [ $configure -eq 0 ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}${SYSCONFDIR}/network/if-up.d 0755
|
|
|
|
make_parent_directory ${DESTDIR}${SYSCONFDIR}/network/if-down.d 0755
|
2014-10-04 18:00:12 +02:00
|
|
|
fi
|
|
|
|
|
2012-03-31 23:42:01 +02:00
|
|
|
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-up.d/shorewall 0544
|
|
|
|
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-down.d/shorewall 0544
|
2012-02-17 22:22:06 +01:00
|
|
|
fi
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
redhat)
|
2013-03-15 18:53:36 +01:00
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
install_local=
|
|
|
|
|
|
|
|
if [ -f ${SBINDIR}/ifup-local -o -f ${SBINDIR}/ifdown-local ]; then
|
2013-10-14 16:15:08 +02:00
|
|
|
if ! grep -qF Shorewall-based ${SBINDIR}/ifup-local || ! grep -qF Shorewall-based ${SBINDIR}/ifdown-local; then
|
2013-03-15 18:53:36 +01:00
|
|
|
echo "WARNING: ${SBINDIR}/ifup-local and/or ${SBINDIR}/ifdown-local already exist; up/down events will not be handled"
|
|
|
|
else
|
|
|
|
install_local=Yes
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
install_local=Yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$install_local" ]; then
|
|
|
|
install_file ifupdown ${DESTDIR}${SBINDIR}/ifup-local 0544
|
|
|
|
install_file ifupdown ${DESTDIR}${SBINDIR}/ifdown-local 0544
|
|
|
|
fi
|
2012-02-17 22:22:06 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2010-05-23 23:44:35 +02:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" ]; then
|
2016-01-05 00:45:21 +01:00
|
|
|
if [ $configure -eq 1 -a -n "first_install" ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
if [ $HOST = debian ]; then
|
2015-12-05 17:31:22 +01:00
|
|
|
if [ -n "$SERVICEDIR" ]; then
|
|
|
|
if systemctl enable ${PRODUCT}.service; then
|
2017-02-20 18:51:46 +01:00
|
|
|
echo "$Product will start automatically at boot"
|
2015-12-05 17:31:22 +01:00
|
|
|
fi
|
|
|
|
elif mywhich insserv; then
|
2017-02-20 18:51:46 +01:00
|
|
|
if insserv ${INITDIR}/$PRODUCT; then
|
|
|
|
echo "$Product will start automatically at boot"
|
2013-09-29 18:28:22 +02:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2013-10-25 15:53:51 +02:00
|
|
|
elif mywhich update-rc.d ; then
|
|
|
|
if update-rc.d $PRODUCT enable; then
|
2017-02-20 18:51:46 +01:00
|
|
|
echo "$Product will start automatically at boot"
|
2013-10-25 15:53:51 +02:00
|
|
|
echo "Set startup=1 in ${CONFDIR}/default/$PRODUCT to enable"
|
|
|
|
else
|
|
|
|
cant_autostart
|
2013-10-25 16:04:03 +02:00
|
|
|
fi
|
2013-09-29 18:28:22 +02:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2016-01-05 00:45:21 +01:00
|
|
|
elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then
|
|
|
|
/etc/init.d/$PRODUCT enable
|
|
|
|
if /etc/init.d/$PRODUCT enabled; then
|
|
|
|
echo "$Product will start automatically at boot"
|
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2013-09-17 17:22:52 +02:00
|
|
|
elif [ $HOST = gentoo ]; then
|
|
|
|
# On Gentoo, a service must be enabled manually by the user,
|
|
|
|
# not by the installer
|
2013-10-03 23:06:08 +02:00
|
|
|
/bin/true
|
2010-05-17 00:35:22 +02:00
|
|
|
else
|
2014-10-13 20:56:26 +02:00
|
|
|
if [ -n "$SERVICEDIR" ]; then
|
2017-02-20 18:51:46 +01:00
|
|
|
if systemctl enable ${PRODUCT}.service; then
|
|
|
|
echo "$Product will start automatically at boot"
|
2011-08-23 23:07:44 +02:00
|
|
|
fi
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -x ${SBINDIR}/insserv -o -x /usr${SBINDIR}/insserv ]; then
|
2017-02-20 18:51:46 +01:00
|
|
|
if insserv ${INITDIR}/$PRODUCT ; then
|
|
|
|
echo "$Product will start automatically at boot"
|
2010-05-17 00:35:22 +02:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -x ${SBINDIR}/chkconfig -o -x /usr${SBINDIR}/chkconfig ]; then
|
2017-02-20 18:51:46 +01:00
|
|
|
if chkconfig --add $PRODUCT ; then
|
|
|
|
echo "$Product will start automatically at boot"
|
|
|
|
chkconfig --list $PRODUCT
|
2010-05-17 00:35:22 +02:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -x ${SBINDIR}/rc-update ]; then
|
2017-02-20 18:51:46 +01:00
|
|
|
if rc-update add $PRODUCT default; then
|
|
|
|
echo "$Product will start automatically at boot"
|
2010-05-17 00:35:22 +02:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2015-12-28 01:47:31 +01:00
|
|
|
elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then
|
2016-04-24 19:02:14 +02:00
|
|
|
/etc/init.d/$PRODUCT enable
|
2017-02-20 18:51:46 +01:00
|
|
|
if /etc/init.d/$PRODUCT enabled; then
|
2016-04-24 19:02:14 +02:00
|
|
|
echo "$Product will start automatically at boot"
|
2015-12-28 01:47:31 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2012-02-21 21:34:41 +01:00
|
|
|
else
|
2010-05-17 00:35:22 +02:00
|
|
|
cant_autostart
|
|
|
|
fi
|
2010-12-05 01:01:16 +01:00
|
|
|
fi
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
2010-05-23 23:10:50 +02:00
|
|
|
else
|
2014-10-03 16:59:41 +02:00
|
|
|
if [ $configure -eq 1 -a -n "$first_install" ]; then
|
2016-06-09 00:56:56 +02:00
|
|
|
if [ $HOST = debian -a -z "$SERVICEDIR" ]; then
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "${DESTDIR}" ]; then
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}/etc/rcS.d 0755
|
2010-05-24 00:34:42 +02:00
|
|
|
fi
|
|
|
|
|
2017-02-20 18:51:46 +01:00
|
|
|
ln -sf ../init.d/$PRODUCT ${DESTDIR}${CONFDIR}/rcS.d/S38${PRODUCT}
|
|
|
|
echo "$Product will start automatically at boot"
|
2010-05-23 23:10:50 +02:00
|
|
|
fi
|
|
|
|
fi
|
2010-12-05 18:11:08 +01:00
|
|
|
fi
|
2010-12-04 21:06:05 +01:00
|
|
|
|
2012-03-30 21:02:25 +02:00
|
|
|
[ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc .
|
|
|
|
|
2015-11-21 21:53:24 +01:00
|
|
|
if [ -d ${DESTDIR}/etc/ppp ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
case $HOST in
|
|
|
|
debian|suse)
|
2012-02-17 22:22:06 +01:00
|
|
|
for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do
|
2017-02-20 18:51:54 +01:00
|
|
|
make_parent_directory ${DESTDIR}/etc/ppp/$directory 0755 #SuSE doesn't create the IPv6 directories
|
2017-02-20 18:51:46 +01:00
|
|
|
cp -fp ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown ${DESTDIR}${CONFDIR}/ppp/$directory/shorewall
|
2012-02-17 22:22:06 +01:00
|
|
|
done
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
redhat)
|
2012-02-17 22:22:06 +01:00
|
|
|
#
|
|
|
|
# Must use the dreaded ip_xxx.local file
|
|
|
|
#
|
|
|
|
for file in ip-up.local ip-down.local; do
|
|
|
|
FILE=${DESTDIR}/etc/ppp/$file
|
|
|
|
if [ -f $FILE ]; then
|
2013-10-14 16:15:08 +02:00
|
|
|
if grep -qF Shorewall-based $FILE ; then
|
2017-02-20 18:51:46 +01:00
|
|
|
cp -fp ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown $FILE
|
2012-02-17 22:22:06 +01:00
|
|
|
else
|
|
|
|
echo "$FILE already exists -- ppp devices will not be handled"
|
|
|
|
break
|
|
|
|
fi
|
2010-12-05 18:11:08 +01:00
|
|
|
else
|
2017-02-20 18:51:46 +01:00
|
|
|
cp -fp ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown $FILE
|
2010-12-05 18:11:08 +01:00
|
|
|
fi
|
2012-02-17 22:22:06 +01:00
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
#
|
2017-02-20 18:51:59 +01:00
|
|
|
# Report Success
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
|
|
|
echo "shorewall Init Version $VERSION Installed"
|