2009-11-04 15:58:49 +01:00
|
|
|
#!/bin/sh
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2006-06-05 21:19:35 +02:00
|
|
|
# Script to install Shoreline Firewall Lite
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2016-02-29 20:03:09 +01:00
|
|
|
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Shorewall documentation is available at http://shorewall.net
|
|
|
|
#
|
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.
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2014-01-04 18:48:27 +01:00
|
|
|
# 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.
|
2006-06-03 17:16:21 +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/>.
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
|
2011-07-13 16:10:07 +02:00
|
|
|
VERSION=xxx #The Build script inserts the actual version
|
2006-06-03 17:16:21 +02:00
|
|
|
|
|
|
|
usage() # $1 = exit status
|
|
|
|
{
|
|
|
|
ME=$(basename $0)
|
2012-03-25 16:49:52 +02:00
|
|
|
echo "usage: $ME [ <configuration-file> ]"
|
2006-06-03 17:16:21 +02:00
|
|
|
echo " $ME -v"
|
|
|
|
echo " $ME -h"
|
2014-10-03 16:59:41 +02:00
|
|
|
echo " $ME -n"
|
2006-06-03 17:16:21 +02:00
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
cant_autostart()
|
|
|
|
{
|
|
|
|
echo
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "WARNING: Unable to configure $Product to start automatically at boot" >&2
|
2006-06-03 17:16:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
install_file() # $1 = source $2 = target $3 = mode
|
|
|
|
{
|
2015-11-04 22:29:59 +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
|
|
|
|
}
|
|
|
|
|
2012-01-04 16:17:58 +01:00
|
|
|
#
|
|
|
|
# Change to the directory containing this script
|
|
|
|
#
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
2016-11-21 19:00:55 +01:00
|
|
|
if [ -f shorewall-lite.service ]; then
|
2012-01-04 16:17:58 +01:00
|
|
|
PRODUCT=shorewall-lite
|
|
|
|
Product="Shorewall Lite"
|
|
|
|
else
|
|
|
|
PRODUCT=shorewall6-lite
|
|
|
|
Product="Shorewall6 Lite"
|
|
|
|
fi
|
|
|
|
|
2017-02-20 18:51:49 +01:00
|
|
|
#
|
|
|
|
# Source common functions
|
|
|
|
#
|
|
|
|
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Parse the run line
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
finished=0
|
2014-10-03 16:59:41 +02:00
|
|
|
configure=1
|
2012-03-24 21:05:39 +01:00
|
|
|
|
|
|
|
while [ $finished -eq 0 ] ; do
|
2014-10-04 01:41:27 +02:00
|
|
|
|
|
|
|
option=$1
|
|
|
|
|
|
|
|
case "$option" in
|
2012-03-24 21:05:39 +01:00
|
|
|
-*)
|
|
|
|
option=${option#-}
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
while [ -n "$option" ]; do
|
|
|
|
case $option in
|
|
|
|
h)
|
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
echo "$Product Firewall Installer Version $VERSION"
|
|
|
|
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
|
2006-06-03 17:16:21 +02:00
|
|
|
;;
|
|
|
|
*)
|
2012-03-24 21:05:39 +01:00
|
|
|
finished=1
|
2006-06-03 17:16:21 +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
|
|
|
|
. ./shorewallrc || exit 1
|
2016-12-19 19:26:55 +01:00
|
|
|
file=./shorewallrc
|
2012-04-01 02:40:18 +02:00
|
|
|
elif [ -f ~/.shorewallrc ]; then
|
2012-03-30 21:02:25 +02:00
|
|
|
. ~/.shorewallrc
|
|
|
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
|
|
|
. /usr/share/shorewall/shorewallrc
|
2012-03-24 21:05:39 +01:00
|
|
|
else
|
2012-03-30 21:02:25 +02:00
|
|
|
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
|
|
|
|
/*|.*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
file=./$file
|
|
|
|
;;
|
|
|
|
esac
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
. $file
|
|
|
|
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
|
|
|
|
|
2015-10-31 20:43:01 +01:00
|
|
|
for var in SHAREDIR LIBEXECDIR CONFDIR SBINDIR VARLIB VARDIR; do
|
2012-03-24 21:05:39 +01:00
|
|
|
require $var
|
|
|
|
done
|
|
|
|
|
2013-08-15 15:51:27 +02:00
|
|
|
[ -n "${INITFILE}" ] && require INITSOURCE && require INITDIR
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
PATH=${SBINDIR}:/bin:/usr${SBINDIR}:/usr/bin:/usr/local/bin:/usr/local${SBINDIR}
|
2011-05-14 14:31:19 +02:00
|
|
|
|
2014-10-04 16:50:30 +02:00
|
|
|
[ -n "$SANDBOX" ] && configure=0
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Determine where to install the firewall script
|
|
|
|
#
|
2012-02-22 22:32:10 +01:00
|
|
|
cygwin=
|
2009-07-25 16:44:53 +02:00
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
if [ -z "$BUILD" ]; then
|
2012-02-17 22:22:06 +01:00
|
|
|
case $(uname) in
|
2014-07-09 20:28:45 +02:00
|
|
|
cygwin*|CYGWIN*)
|
2012-02-22 22:32:10 +01:00
|
|
|
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
|
|
|
|
eval $(cat /etc/os-release | grep ^ID)
|
|
|
|
|
|
|
|
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
|
|
|
|
;;
|
|
|
|
debian)
|
|
|
|
BUILD=debian
|
|
|
|
;;
|
2013-09-17 17:22:52 +02:00
|
|
|
gentoo)
|
|
|
|
BUILD=gentoo
|
|
|
|
;;
|
2013-08-09 02:44:40 +02:00
|
|
|
opensuse)
|
|
|
|
BUILD=suse
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
BUILD="$ID"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
elif [ -f ${CONFDIR}/debian_version ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=debian
|
2013-09-17 17:22:52 +02:00
|
|
|
elif [ -f /etc/gentoo-release ]; then
|
|
|
|
BUILD=gentoo
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -f ${CONFDIR}/redhat-release ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=redhat
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -f ${CONFDIR}/SuSE-release ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=suse
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -f ${CONFDIR}/slackware-version ] ; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=slackware
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ -f ${CONFDIR}/arch-release ] ; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=archlinux
|
2015-11-06 23:01:02 +01:00
|
|
|
elif [ -f ${CONFDIR}/openwrt_release ]; then
|
2015-11-04 22:29:59 +01:00
|
|
|
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
|
2014-07-09 20:28:45 +02:00
|
|
|
cygwin*|CYGWIN*)
|
2009-07-25 16:44:53 +02:00
|
|
|
OWNER=$(id -un)
|
|
|
|
GROUP=$(id -gn)
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
apple)
|
2012-02-17 22:22:06 +01:00
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=wheel
|
|
|
|
;;
|
2009-07-25 16:44:53 +02:00
|
|
|
*)
|
2015-11-06 23:01:02 +01:00
|
|
|
if [ $(id -u) -eq 0 ]; then
|
2015-11-04 22:29:59 +01:00
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=root
|
|
|
|
fi
|
2009-07-25 16:44:53 +02:00
|
|
|
;;
|
|
|
|
esac
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2015-11-04 22:29:59 +01:00
|
|
|
[ -n "$OWNER" ] && OWNERSHIP="$OWNER:$GROUP"
|
2006-06-03 17:16:21 +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
|
|
|
|
cygwin)
|
2012-02-21 21:34:41 +01:00
|
|
|
echo "$PRODUCT is not supported on Cygwin" >&2
|
|
|
|
exit 1
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
apple)
|
2012-02-21 21:34:41 +01:00
|
|
|
echo "$PRODUCT is not supported on OS X" >&2
|
|
|
|
exit 1
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
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..."
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
redhat)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Installing Redhat/Fedora-specific configuration..."
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
slackware)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Installing Slackware-specific configuration..."
|
|
|
|
;;
|
2012-02-22 22:32:10 +01:00
|
|
|
archlinux)
|
2012-02-17 22:22:06 +01:00
|
|
|
echo "Installing ArchLinux-specific configuration..."
|
|
|
|
;;
|
2012-08-26 17:14:23 +02:00
|
|
|
suse)
|
|
|
|
echo "Installing Suse-specific configuration..."
|
|
|
|
;;
|
2015-11-04 22:29:59 +01:00
|
|
|
openwrt)
|
|
|
|
echo "Installing OpenWRT-specific configuration..."
|
|
|
|
;;
|
2012-08-26 17:14:23 +02:00
|
|
|
linux)
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
|
|
|
*)
|
2012-02-22 22:32:10 +01:00
|
|
|
echo "ERROR: Unknown HOST \"$HOST\"" >&2
|
2012-02-17 22:22:06 +01:00
|
|
|
exit 1;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
[ -z "$INITDIR" ] && INITDIR="${CONFDIR}/init.d"
|
2012-02-20 19:08:42 +01:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "$DESTDIR" ]; then
|
2009-07-25 16:44:53 +02:00
|
|
|
if [ `id -u` != 0 ] ; then
|
|
|
|
echo "Not setting file owner/group permissions, not running as root."
|
|
|
|
OWNERSHIP=""
|
|
|
|
fi
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2015-11-04 22:29:59 +01:00
|
|
|
make_directory ${DESTDIR}${INITDIR} 755
|
|
|
|
|
2012-02-17 22:22:06 +01:00
|
|
|
else
|
2013-09-12 22:55:30 +02:00
|
|
|
if [ ! -f ${SHAREDIR}/shorewall/coreversion ]; then
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "$PRODUCT $VERSION requires Shorewall Core which does not appear to be installed" >&2
|
2012-01-02 05:30:09 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2011-08-23 23:07:44 +02:00
|
|
|
fi
|
|
|
|
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "Installing $Product Version $VERSION"
|
2006-06-03 17:16:21 +02:00
|
|
|
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
# Check for ${CONFDIR}/$PRODUCT
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -z "$DESTDIR" -a -d ${CONFDIR}/$PRODUCT ]; then
|
2013-09-09 16:40:18 +02:00
|
|
|
if [ ! -f ${SHAREDIR}/shorewall/coreversion ]; then
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "$PRODUCT $VERSION requires Shorewall Core which does not appear to be installed" >&2
|
2012-01-02 05:30:09 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
[ -f ${CONFDIR}/$PRODUCT/shorewall.conf ] && \
|
|
|
|
mv -f ${CONFDIR}/$PRODUCT/shorewall.conf ${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
2006-06-03 17:16:21 +02:00
|
|
|
else
|
2012-03-24 21:05:39 +01:00
|
|
|
rm -rf ${DESTDIR}${CONFDIR}/$PRODUCT
|
2012-08-17 23:24:52 +02:00
|
|
|
rm -rf ${DESTDIR}${SHAREDIR}/$PRODUCT
|
2012-09-02 23:36:11 +02:00
|
|
|
rm -rf ${DESTDIR}${VARDIR}
|
2012-03-24 21:05:39 +01:00
|
|
|
[ "$LIBEXECDIR" = /usr/share ] || rm -rf ${DESTDIR}/usr/share/$PRODUCT/wait4ifup ${DESTDIR}/usr/share/$PRODUCT/shorecap
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
|
2010-04-07 22:16:16 +02:00
|
|
|
#
|
2016-11-21 19:00:55 +01:00
|
|
|
# Check for ${SHAREDIR}/$PRODUCT/version
|
2010-04-07 22:16:16 +02:00
|
|
|
#
|
2016-11-21 19:00:55 +01:00
|
|
|
if [ -f ${DESTDIR}${SHAREDIR}/$PRODUCT/version ]; then
|
2010-04-07 22:16:16 +02:00
|
|
|
first_install=""
|
|
|
|
else
|
|
|
|
first_install="Yes"
|
|
|
|
fi
|
|
|
|
|
2012-01-04 16:17:58 +01:00
|
|
|
delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules
|
2006-09-07 22:48:40 +02:00
|
|
|
|
2015-11-04 22:29:59 +01:00
|
|
|
[ -n "${INITFILE}" ] && make_directory ${DESTDIR}${INITDIR} 755
|
2006-06-12 19:48:20 +02:00
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
# Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT
|
2012-08-17 23:24:52 +02:00
|
|
|
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT
|
2012-03-24 21:05:39 +01:00
|
|
|
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
|
2016-12-18 20:48:05 +01:00
|
|
|
mkdir -p ${DESTDIR}${SBINDIR}
|
2012-09-02 23:36:11 +02:00
|
|
|
mkdir -p ${DESTDIR}${VARDIR}
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
|
2014-10-05 02:48:20 +02:00
|
|
|
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -n "$DESTDIR" ]; then
|
2012-03-24 21:05:39 +01:00
|
|
|
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d
|
|
|
|
chmod 755 ${DESTDIR}${CONFDIR}/logrotate.d
|
2012-02-21 23:24:50 +01:00
|
|
|
mkdir -p ${DESTDIR}${INITDIR}
|
|
|
|
chmod 755 ${DESTDIR}${INITDIR}
|
2009-11-03 19:06:10 +01:00
|
|
|
fi
|
|
|
|
|
2012-02-23 19:59:10 +01:00
|
|
|
if [ -n "$INITFILE" ]; then
|
2013-08-15 15:51:27 +02:00
|
|
|
if [ -f "${INITSOURCE}" ]; then
|
2014-11-15 16:46:44 +01:00
|
|
|
initfile="${DESTDIR}${INITDIR}/${INITFILE}"
|
2013-08-15 15:51:27 +02:00
|
|
|
install_file ${INITSOURCE} "$initfile" 0544
|
2012-03-31 01:21:37 +02:00
|
|
|
|
2013-08-15 15:51:27 +02:00
|
|
|
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
|
2012-03-31 01:21:37 +02:00
|
|
|
|
2013-09-09 17:11:45 +02:00
|
|
|
echo "SysV init script $INITSOURCE installed in $initfile"
|
2013-08-15 15:51:27 +02:00
|
|
|
fi
|
2012-02-23 19:59:10 +01:00
|
|
|
fi
|
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
|
|
|
|
mkdir -p ${DESTDIR}${SERVICEDIR}
|
2013-08-18 23:27:26 +02:00
|
|
|
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
2015-11-04 22:29:59 +01:00
|
|
|
install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 644
|
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"
|
2011-08-23 23:07:44 +02:00
|
|
|
fi
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Install the config file
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf ]; then
|
|
|
|
install_file $PRODUCT.conf ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf 0744
|
|
|
|
echo "Config file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf"
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
|
2012-02-22 22:32:10 +01:00
|
|
|
if [ $HOST = archlinux ] ; then
|
2012-03-24 21:05:39 +01:00
|
|
|
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
2017-01-06 18:49:40 +01:00
|
|
|
elif [ $HOST = gentoo ]; then
|
|
|
|
# Adjust SUBSYSLOCK path (see https://bugs.gentoo.org/show_bug.cgi?id=459316)
|
|
|
|
perl -p -w -i -e "s|^SUBSYSLOCK=.*|SUBSYSLOCK=/run/lock/$PRODUCT|;" ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
2006-06-03 19:04:45 +02:00
|
|
|
#
|
|
|
|
# Install the default config path file
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
install_file configpath ${DESTDIR}${SHAREDIR}/$PRODUCT/configpath 0644
|
|
|
|
echo "Default config path file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/configpath"
|
2006-06-03 19:04:45 +02:00
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2012-03-31 21:57:38 +02:00
|
|
|
# Install the libraries
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2012-03-31 21:57:38 +02:00
|
|
|
for f in lib.* ; do
|
|
|
|
if [ -f $f ]; then
|
|
|
|
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
|
2015-10-31 20:57:33 +01:00
|
|
|
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
|
2012-03-31 21:57:38 +02:00
|
|
|
fi
|
2012-03-31 00:30:04 +02:00
|
|
|
done
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2012-03-31 21:57:38 +02:00
|
|
|
ln -sf lib.base ${DESTDIR}${SHAREDIR}/$PRODUCT/functions
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "Common functions linked through ${DESTDIR}${SHAREDIR}/$PRODUCT/functions"
|
2006-06-03 17:16:21 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install Shorecap
|
|
|
|
#
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
install_file shorecap ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap 0755
|
2015-10-31 20:57:33 +01:00
|
|
|
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap
|
2006-06-03 17:16:21 +02:00
|
|
|
|
|
|
|
echo
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap"
|
2007-01-01 01:40:42 +01:00
|
|
|
|
2006-06-05 23:04:19 +02:00
|
|
|
#
|
2011-02-06 03:19:04 +01:00
|
|
|
# Install the Modules files
|
2006-06-05 23:04:19 +02:00
|
|
|
#
|
2010-05-24 01:26:14 +02:00
|
|
|
|
|
|
|
if [ -f modules ]; then
|
2015-11-04 22:29:59 +01:00
|
|
|
install_file modules ${DESTDIR}${SHAREDIR}/$PRODUCT/modules 0600
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "Modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/modules"
|
2010-05-24 01:26:14 +02:00
|
|
|
fi
|
2006-06-05 23:04:19 +02:00
|
|
|
|
2011-03-19 22:14:03 +01:00
|
|
|
if [ -f helpers ]; then
|
2015-11-04 22:29:59 +01:00
|
|
|
install_file helpers ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers 600
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "Helper modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers"
|
2011-03-19 22:14:03 +01:00
|
|
|
fi
|
|
|
|
|
2011-02-06 03:19:04 +01:00
|
|
|
for f in modules.*; do
|
2015-11-04 22:29:59 +01:00
|
|
|
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 644
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
|
2011-02-06 03:19:04 +01:00
|
|
|
done
|
|
|
|
|
2006-11-19 05:13:06 +01:00
|
|
|
#
|
|
|
|
# Install the Man Pages
|
|
|
|
#
|
|
|
|
|
2016-04-24 19:02:14 +02:00
|
|
|
if [ -d manpages -a -n "$MANDIR" ]; then
|
2010-05-24 01:26:14 +02:00
|
|
|
cd manpages
|
2006-11-19 05:13:06 +01:00
|
|
|
|
2016-11-21 19:00:55 +01:00
|
|
|
mkdir -p ${DESTDIR}${MANDIR}/man5/
|
2010-05-09 01:32:03 +02:00
|
|
|
|
2010-05-24 01:26:14 +02:00
|
|
|
for f in *.5; do
|
|
|
|
gzip -c $f > $f.gz
|
2015-11-04 22:29:59 +01:00
|
|
|
install_file $f.gz ${DESTDIR}${MANDIR}/man5/$f.gz 644
|
2014-10-04 23:26:12 +02:00
|
|
|
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
|
2010-05-24 01:26:14 +02:00
|
|
|
done
|
2006-11-19 05:13:06 +01:00
|
|
|
|
2016-12-19 01:16:50 +01:00
|
|
|
mkdir -p ${DESTDIR}${MANDIR}/man8/
|
|
|
|
|
|
|
|
for f in *.8; do
|
|
|
|
gzip -c $f > $f.gz
|
|
|
|
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644
|
|
|
|
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz"
|
|
|
|
done
|
|
|
|
|
2010-05-24 01:26:14 +02:00
|
|
|
cd ..
|
2006-11-19 05:13:06 +01:00
|
|
|
|
2010-05-24 01:26:14 +02:00
|
|
|
echo "Man Pages Installed"
|
|
|
|
fi
|
2006-11-19 05:13:06 +01:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then
|
2015-11-04 22:29:59 +01:00
|
|
|
install_file logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT 644
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT"
|
2009-11-03 19:06:10 +01:00
|
|
|
fi
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Create the version file
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "$VERSION" > ${DESTDIR}${SHAREDIR}/$PRODUCT/version
|
|
|
|
chmod 644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Remove and create the symbolic link to the init script
|
|
|
|
#
|
|
|
|
|
2014-10-03 02:42:08 +02:00
|
|
|
if [ -z "${DESTDIR}" -a -n "${INITFILE}" ]; then
|
2012-03-24 21:05:39 +01:00
|
|
|
rm -f ${SHAREDIR}/$PRODUCT/init
|
|
|
|
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.common
|
|
|
|
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.cli
|
|
|
|
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/wait4ifup
|
2016-12-18 20:48:05 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Creatae the symbolic link for the CLI
|
|
|
|
#
|
|
|
|
ln -sf shorewall ${DESTDIR}${SBINDIR}/${PRODUCT}
|
2010-04-10 20:46:50 +02:00
|
|
|
|
2013-09-10 17:24:27 +02:00
|
|
|
#
|
|
|
|
# Note -- not all packages will have the SYSCONFFILE so we need to check for its existance here
|
|
|
|
#
|
|
|
|
if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ ${DESTDIR} ]; then
|
|
|
|
mkdir -p ${DESTDIR}${SYSCONFDIR}
|
|
|
|
chmod 755 ${DESTDIR}${SYSCONFDIR}
|
|
|
|
fi
|
2010-10-13 17:42:35 +02:00
|
|
|
|
2015-11-06 23:01:02 +01:00
|
|
|
install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} 0640
|
2016-05-29 11:00:52 +02:00
|
|
|
echo "$SYSCONFFILE file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
|
2012-03-24 21:05:39 +01:00
|
|
|
fi
|
2010-06-25 20:14:55 +02:00
|
|
|
|
2012-03-30 21:02:25 +02:00
|
|
|
if [ ${SHAREDIR} != /usr/share ]; then
|
2015-10-31 20:57:33 +01:00
|
|
|
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
|
2012-03-30 21:02:25 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-03 16:59:41 +02:00
|
|
|
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
2014-10-13 20:56:26 +02:00
|
|
|
if [ -n "$SERVICEDIR" ]; then
|
2012-07-14 23:38:30 +02:00
|
|
|
if systemctl enable ${PRODUCT}.service; then
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "$Product will start automatically at boot"
|
2012-03-24 21:05:39 +01:00
|
|
|
fi
|
|
|
|
elif mywhich insserv; then
|
|
|
|
if insserv ${INITDIR}/${INITFILE} ; then
|
|
|
|
echo "$PRODUCT will start automatically at boot"
|
2013-09-29 18:28:22 +02:00
|
|
|
if [ $HOST = debian ]; then
|
|
|
|
echo "Set startup=1 in ${CONFDIR}/default/$PRODUCT to enable"
|
|
|
|
touch /var/log/$PRODUCT-init.log
|
2017-01-06 18:49:40 +01:00
|
|
|
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
2013-09-29 18:28:22 +02:00
|
|
|
else
|
|
|
|
echo "Set STARTUP_ENABLED=Yes in ${CONFDIR}/$PRODUCT/$PRODUCT.conf to enable"
|
|
|
|
fi
|
2010-04-10 20:46:50 +02:00
|
|
|
else
|
2012-03-24 21:05:39 +01:00
|
|
|
cant_autostart
|
|
|
|
fi
|
|
|
|
elif mywhich chkconfig; then
|
|
|
|
if chkconfig --add $PRODUCT ; then
|
|
|
|
echo "$PRODUCT will start automatically in run levels as follows:"
|
|
|
|
echo "Set STARTUP_ENABLED=Yes in ${CONFDIR}/$PRODUCT/${PRODUCT}.conf to enable"
|
|
|
|
chkconfig --list $PRODUCT
|
|
|
|
else
|
|
|
|
cant_autostart
|
|
|
|
fi
|
2013-10-25 15:53:51 +02:00
|
|
|
elif mywhich update-rc.d ; then
|
|
|
|
echo "$PRODUCT will start automatically at boot"
|
|
|
|
echo "Set startup=1 in ${CONFDIR}/default/$PRODUCT to enable"
|
|
|
|
touch /var/log/$PRODUCT-init.log
|
2017-01-06 18:49:40 +01:00
|
|
|
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
2013-10-25 15:53:51 +02:00
|
|
|
update-rc.d $PRODUCT enable
|
2012-03-24 21:05:39 +01:00
|
|
|
elif mywhich rc-update ; then
|
|
|
|
if rc-update add $PRODUCT default; then
|
|
|
|
echo "$PRODUCT will start automatically at boot"
|
2013-09-29 18:28:22 +02:00
|
|
|
if [ $HOST = debian ]; then
|
|
|
|
echo "Set startup=1 in ${CONFDIR}/default/$PRODUCT to enable"
|
|
|
|
touch /var/log/$PRODUCT-init.log
|
2017-01-06 18:49:40 +01:00
|
|
|
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
2013-09-29 18:28:22 +02:00
|
|
|
else
|
|
|
|
echo "Set STARTUP_ENABLED=Yes in ${CONFDIR}/$PRODUCT/$PRODUCT.conf to enable"
|
|
|
|
fi
|
2012-03-24 21:05:39 +01:00
|
|
|
else
|
|
|
|
cant_autostart
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
2015-11-06 23:01:02 +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
|
2012-03-24 21:05:39 +01:00
|
|
|
elif [ "$INITFILE" != rc.${PRODUCT} ]; then #Slackware starts this automatically
|
|
|
|
cant_autostart
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Report Success
|
|
|
|
#
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "$Product Version $VERSION Installed"
|