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
|
|
|
#
|
2007-09-08 18:09:51 +02:00
|
|
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
2011-05-23 19:06:56 +02:00
|
|
|
# (c) 2000-2011 - Tom Eastep (teastep@shorewall.net)
|
2006-06-03 17:16:21 +02: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
|
2007-09-08 18:09:51 +02:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
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"
|
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
fatal_error()
|
|
|
|
{
|
|
|
|
echo " ERROR: $@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
split() {
|
2008-03-14 03:07:28 +01:00
|
|
|
local ifs
|
|
|
|
ifs=$IFS
|
2006-06-03 17:16:21 +02:00
|
|
|
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
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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}
|
2006-06-03 17:16:21 +02:00
|
|
|
}
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
require()
|
|
|
|
{
|
|
|
|
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
|
|
|
|
}
|
|
|
|
|
2012-01-04 16:17:58 +01:00
|
|
|
#
|
|
|
|
# Change to the directory containing this script
|
|
|
|
#
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
|
|
|
if [ -f shorewall-lite ]; then
|
|
|
|
PRODUCT=shorewall-lite
|
|
|
|
Product="Shorewall Lite"
|
|
|
|
else
|
|
|
|
PRODUCT=shorewall6-lite
|
|
|
|
Product="Shorewall6 Lite"
|
|
|
|
fi
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Parse the run line
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
finished=0
|
|
|
|
|
|
|
|
while [ $finished -eq 0 ] ; do
|
2006-06-03 17:16:21 +02:00
|
|
|
case "$1" in
|
2012-03-24 21:05:39 +01:00
|
|
|
-*)
|
|
|
|
option=${option#-}
|
|
|
|
|
|
|
|
while [ -n "$option" ]; do
|
|
|
|
case $option in
|
|
|
|
h)
|
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
echo "$Product Firewall Installer Version $VERSION"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
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-03-30 21:02:25 +02:00
|
|
|
if [ -f ~/.shorewallrc ]; then
|
|
|
|
. ~/.shorewallrc
|
2012-03-31 23:42:01 +02:00
|
|
|
elif [ -f ./.shorewallrc ]; then
|
|
|
|
. ./.shorewallrc || exit 1
|
|
|
|
file=./.shorewallrc
|
2012-03-30 21:02:25 +02:00
|
|
|
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-03-24 21:05:39 +01:00
|
|
|
for var in SHAREDIR LIBEXECDIRDIRDIR CONFDIR SBINDIR VARDIR; do
|
|
|
|
require $var
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH=${SBINDIR}:/bin:/usr${SBINDIR}:/usr/bin:/usr/local/bin:/usr/local${SBINDIR}
|
2011-05-14 14:31:19 +02:00
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
#
|
|
|
|
# Determine where to install the firewall script
|
|
|
|
#
|
2012-02-22 22:32:10 +01:00
|
|
|
cygwin=
|
2010-05-09 01:32:03 +02:00
|
|
|
INSTALLD='-D'
|
2012-02-21 21:34:41 +01:00
|
|
|
INITFILE=$PRODUCT
|
2010-05-29 19:50:39 +02:00
|
|
|
T='-T'
|
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
|
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
|
|
|
;;
|
|
|
|
*)
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -f ${CONFDIR}/debian_version ]; then
|
2012-02-22 22:32:10 +01:00
|
|
|
BUILD=debian
|
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
|
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
|
|
|
|
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
|
2010-05-29 19:57:27 +02:00
|
|
|
INSTALLD=
|
2010-05-29 19:50:39 +02:00
|
|
|
T=
|
2012-02-17 22:22:06 +01:00
|
|
|
;;
|
2009-07-25 16:44:53 +02:00
|
|
|
*)
|
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=root
|
|
|
|
;;
|
|
|
|
esac
|
2006-06-03 17:16:21 +02:00
|
|
|
|
|
|
|
OWNERSHIP="-o $OWNER -g $GROUP"
|
|
|
|
|
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..."
|
|
|
|
;;
|
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-02-22 22:32:10 +01:00
|
|
|
linux|suse)
|
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-03-24 21:05:39 +01:00
|
|
|
install -d $OWNERSHIP -m 755 ${DESTDIR}/${SBINDIR}
|
|
|
|
install -d $OWNERSHIP -m 755 ${DESTDIR}${INITDIR}
|
2006-11-12 17:00:38 +01:00
|
|
|
|
2012-02-17 22:22:06 +01:00
|
|
|
if [ -n "$SYSTEMD" ]; then
|
|
|
|
mkdir -p ${DESTDIR}/lib/systemd/system
|
2012-02-23 19:59:10 +01:00
|
|
|
INITFILE=
|
2012-02-17 22:22:06 +01:00
|
|
|
fi
|
|
|
|
else
|
2012-01-02 05:30:09 +01:00
|
|
|
if [ ! -f /usr/share/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
|
|
|
if [ -f /lib/systemd/system ]; then
|
|
|
|
SYSTEMD=Yes
|
2012-02-23 19:59:10 +01:00
|
|
|
INITFILE=
|
2011-08-23 23:07:44 +02:00
|
|
|
fi
|
|
|
|
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
|
2012-01-02 05:30:09 +01:00
|
|
|
if [ ! -f /usr/share/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-01-04 16:17:58 +01:00
|
|
|
rm -rf ${DESTDIR}/usr/share/$PRODUCT
|
|
|
|
rm -rf ${DESTDIR}/var/lib/$PRODUCT
|
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
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
# Check for ${SBINDIR}/$PRODUCT
|
2010-04-07 22:16:16 +02:00
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -f ${DESTDIR}${SBINDIR}/$PRODUCT ]; 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
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0544
|
2006-06-12 19:48:20 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
|
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-01-04 16:17:58 +01:00
|
|
|
mkdir -p ${DESTDIR}/usr/share/$PRODUCT
|
2012-03-24 21:05:39 +01:00
|
|
|
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
|
2012-01-04 16:17:58 +01:00
|
|
|
mkdir -p ${DESTDIR}/var/lib/$PRODUCT
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
|
2012-01-04 16:17:58 +01:00
|
|
|
chmod 755 ${DESTDIR}/usr/share/$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
|
2012-03-31 01:21:37 +02:00
|
|
|
|
|
|
|
initfile="${DESTDIR}/${INITDIR}/${INITFILE}"
|
|
|
|
|
2012-02-23 19:59:10 +01:00
|
|
|
case $TARGET in
|
|
|
|
debian)
|
2012-03-31 01:21:37 +02:00
|
|
|
install_file init.debian.sh "$initfile" 0544
|
2012-02-23 19:59:10 +01:00
|
|
|
;;
|
|
|
|
redhat)
|
2012-03-31 01:21:37 +02:00
|
|
|
install_file init.fedora.sh "$initfile" 0544
|
2012-02-23 19:59:10 +01:00
|
|
|
;;
|
|
|
|
archlinux)
|
2012-03-31 01:21:37 +02:00
|
|
|
install_file init.archlinux.sh "$initfile" 0544
|
2012-02-23 19:59:10 +01:00
|
|
|
;;
|
|
|
|
*)
|
2012-03-31 01:21:37 +02:00
|
|
|
install_file init.sh "$initfile" 0544
|
2012-02-23 19:59:10 +01:00
|
|
|
;;
|
|
|
|
esac
|
2012-02-21 23:24:50 +01:00
|
|
|
|
2012-04-01 00:25:18 +02:00
|
|
|
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' "$initfile"
|
2012-03-31 01:21:37 +02:00
|
|
|
|
2012-02-23 19:59:10 +01:00
|
|
|
echo "$Product init script installed in ${DESTDIR}${INITDIR}/${INITFILE}"
|
|
|
|
fi
|
2011-08-23 23:07:44 +02:00
|
|
|
#
|
|
|
|
# Install the .service file
|
|
|
|
#
|
|
|
|
if [ -n "$SYSTEMD" ]; then
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $OWNERSHIP -m 600 $PRODUCT.service ${DESTDIR}/${SYSTEMD}/$PRODUCT.service
|
2012-01-04 16:17:58 +01:00
|
|
|
echo "Service file installed as ${DESTDIR}/lib/systemd/system/$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
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
|
2006-06-05 19:13:48 +02:00
|
|
|
#
|
|
|
|
# Install the Makefile
|
|
|
|
#
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $OWNERSHIP -m 0600 Makefile ${DESTDIR}${CONFDIR}/$PRODUCT
|
|
|
|
echo "Makefile installed as ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile"
|
2006-06-09 18:59:14 +02:00
|
|
|
|
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
|
|
|
|
echo "Library ${f#*.} file installed as ${DESTDIR}/${SHAREDIR}/$PRODUCT/$f"
|
|
|
|
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
|
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
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $OWNERSHIP -m 0600 modules ${DESTDIR}${SHAREDIR}/$PRODUCT
|
|
|
|
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
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $OWNERSHIP -m 0600 helpers ${DESTDIR}${SHAREDIR}/$PRODUCT
|
|
|
|
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
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $OWNERSHIP -m 0644 $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f
|
|
|
|
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
|
|
|
|
#
|
|
|
|
|
2010-05-24 01:26:14 +02:00
|
|
|
if [ -d manpages ]; then
|
|
|
|
cd manpages
|
2006-11-19 05:13:06 +01:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${SHAREDIR}/man/man5/ ${DESTDIR}${SHAREDIR}/man/man8/
|
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
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${SHAREDIR}/man/man5/$f.gz
|
|
|
|
echo "Man page $f.gz installed to ${DESTDIR}${SHAREDIR}/man/man5/$f.gz"
|
2010-05-24 01:26:14 +02:00
|
|
|
done
|
2006-11-19 05:13:06 +01:00
|
|
|
|
2010-05-24 01:26:14 +02:00
|
|
|
for f in *.8; do
|
|
|
|
gzip -c $f > $f.gz
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${SHAREDIR}/man/man8/$f.gz
|
|
|
|
echo "Man page $f.gz installed to ${DESTDIR}${SHAREDIR}/man/man8/$f.gz"
|
2010-05-24 01:26:14 +02:00
|
|
|
done
|
2006-11-19 05:13:06 +01:00
|
|
|
|
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
|
|
|
|
run_install $OWNERSHIP -m 0644 logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT
|
|
|
|
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
|
|
|
|
#
|
|
|
|
|
2010-06-01 15:42:11 +02:00
|
|
|
if [ -z "$DESTDIR" ]; 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
|
2010-04-10 20:46:50 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -n "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then
|
|
|
|
if [ ${DESTDIR} ]; then
|
|
|
|
mkdir -p ${DESTDIR}${SYSCONFDIR}
|
|
|
|
chmod 755 ${DESTDIR}${SYSCONFDIR}
|
|
|
|
fi
|
2010-10-13 17:42:35 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
run_install $OWNERSHIP -m 0644 default.debian ${DESTDIR}${SYSCONFDIR}/${PRODUCT}
|
|
|
|
echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
|
|
|
|
fi
|
2010-06-25 20:14:55 +02:00
|
|
|
|
2012-03-30 21:02:25 +02:00
|
|
|
if [ ${SHAREDIR} != /usr/share ]; then
|
|
|
|
[ $PRODUCT = shorewall ] && eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SHAREDIR}/lib.base
|
|
|
|
sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SBINDIR}/$PRODUCT
|
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
|
|
|
if mywhich update-rc.d ; then
|
|
|
|
echo "$PRODUCT will start automatically at boot"
|
|
|
|
echo "Set startup=1 in ${SYSCONFDIR}/$PRODUCT to enable"
|
|
|
|
touch /var/log/$PRODUCT-init.log
|
|
|
|
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
|
|
|
|
elif [ -n "$SYSTEMD" ]; then
|
|
|
|
if systemctl enable $PRODUCT; 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"
|
|
|
|
echo "Set STARTUP_ENABLED=Yes in ${CONFDIR}/$PRODUCT/${PRODUCT}.conf to enable"
|
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
|
|
|
|
elif mywhich rc-update ; then
|
|
|
|
if rc-update add $PRODUCT default; then
|
|
|
|
echo "$PRODUCT will start automatically at boot"
|
|
|
|
echo "Set STARTUP_ENABLED=Yes in ${CONFDIR}/$PRODUCT/$PRODUCT.conf to enable"
|
|
|
|
else
|
|
|
|
cant_autostart
|
2006-06-03 17:16:21 +02:00
|
|
|
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"
|