2012-03-27 23:33:49 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2014-01-04 18:48:27 +01:00
|
|
|
# Shorewall Packet Filtering Firewall RPM configuration program - V4.6
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
2014-01-04 18:48:27 +01:00
|
|
|
# (c) 2012,2014 - Tom Eastep (teastep@shorewall.net)
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
|
|
|
# Shorewall documentation is available at http://www.shorewall.net
|
|
|
|
#
|
2014-01-04 18:48:27 +01:00
|
|
|
# This program is part of Shorewall.
|
|
|
|
#
|
2012-03-27 23:33:49 +02:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
2014-01-04 18:48:27 +01:00
|
|
|
# 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.
|
2012-03-27 23:33:49 +02: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.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2014-01-04 18:48:27 +01:00
|
|
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
2012-04-12 23:43:02 +02:00
|
|
|
# Usage: ./configure [ <option>=<setting> ] ...
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
|
|
|
#
|
|
|
|
################################################################################################
|
2012-04-12 23:43:02 +02:00
|
|
|
#
|
|
|
|
# Build updates this
|
|
|
|
#
|
2015-08-01 20:23:35 +02:00
|
|
|
VERSION=4.6.12
|
2012-04-12 23:43:02 +02:00
|
|
|
|
|
|
|
case "$BASH_VERSION" in
|
|
|
|
[4-9].*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: This program requires Bash 4.0 or later" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-03-27 23:33:49 +02:00
|
|
|
declare -A params
|
|
|
|
declare -A options
|
|
|
|
|
|
|
|
getfileparams() {
|
|
|
|
while read option; do
|
|
|
|
case $option in
|
|
|
|
\#*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
on=${option%=*}
|
|
|
|
ov=${option#*=}
|
|
|
|
ov=${ov%#*}
|
|
|
|
[ -n "$on" ] && options[${on}]="${ov}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
done
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2012-03-27 23:33:49 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
for p in $@; do
|
2012-03-29 16:40:15 +02:00
|
|
|
|
2012-03-30 03:53:21 +02:00
|
|
|
if [ -n "${p}" ]; then
|
2012-03-30 04:05:17 +02:00
|
|
|
declare -u pn
|
|
|
|
|
2012-03-30 03:53:21 +02:00
|
|
|
pn=${p%=*}
|
2012-04-12 23:43:02 +02:00
|
|
|
pn=${pn#--}
|
2012-03-30 03:53:21 +02:00
|
|
|
pv=${p#*=}
|
2012-03-29 16:40:15 +02:00
|
|
|
|
2012-03-30 03:53:21 +02:00
|
|
|
if [ -n "${pn}" ]; then
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2012-03-30 03:53:21 +02:00
|
|
|
case ${pn} in
|
|
|
|
VENDOR)
|
|
|
|
pn=HOST
|
|
|
|
;;
|
|
|
|
SHAREDSTATEDIR)
|
2012-09-02 23:36:11 +02:00
|
|
|
pn=VARLIB
|
2012-03-30 03:53:21 +02:00
|
|
|
;;
|
|
|
|
DATADIR)
|
|
|
|
pn=SHAREDIR
|
|
|
|
;;
|
|
|
|
esac
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2012-03-30 03:53:21 +02:00
|
|
|
params[${pn}]="${pv}"
|
2012-04-12 23:43:02 +02:00
|
|
|
else
|
|
|
|
echo "ERROR: Invalid option ($p)" >&2
|
|
|
|
exit 1
|
2012-03-30 03:53:21 +02:00
|
|
|
fi
|
2012-03-29 16:40:15 +02:00
|
|
|
fi
|
2012-03-27 23:33:49 +02:00
|
|
|
done
|
|
|
|
|
2012-03-28 15:13:10 +02:00
|
|
|
vendor=${params[HOST]}
|
2012-03-29 02:01:43 +02:00
|
|
|
|
2012-03-27 23:33:49 +02:00
|
|
|
if [ -z "$vendor" ]; then
|
2013-08-09 02:44:40 +02:00
|
|
|
if [ -f /etc/os-release ]; then
|
2013-10-09 16:14:55 +02:00
|
|
|
eval $(cat /etc/os-release | grep ^ID=)
|
2013-08-09 02:44:40 +02:00
|
|
|
|
|
|
|
case $ID in
|
2014-05-20 00:15:52 +02:00
|
|
|
fedora|rhel)
|
2013-08-09 02:44:40 +02:00
|
|
|
vendor=redhat
|
|
|
|
;;
|
2013-10-09 16:14:55 +02:00
|
|
|
debian|ubuntu)
|
2015-08-01 20:23:35 +02:00
|
|
|
ls -l /sbin/init |fgrep -q systemd | vendor=debian.systemd | vendor=debian.sysvinit
|
2013-08-09 02:44:40 +02:00
|
|
|
;;
|
|
|
|
opensuse)
|
|
|
|
vendor=suse
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
vendor="$ID"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-08-10 01:56:48 +02:00
|
|
|
params[HOST]="$vendor"
|
2013-08-09 02:44:40 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-08-10 03:35:32 +02:00
|
|
|
if [ -z "$vendor" ]; then
|
2012-04-12 23:43:02 +02:00
|
|
|
case `uname` in
|
|
|
|
Darwin)
|
2013-08-10 01:56:48 +02:00
|
|
|
params[HOST]=apple
|
2012-04-12 23:43:02 +02:00
|
|
|
rcfile=shorewallrc.apple
|
|
|
|
;;
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2013-08-10 03:35:32 +02:00
|
|
|
cygwin*|CYGWIN*)
|
2013-08-10 01:56:48 +02:00
|
|
|
params[HOST]=cygwin
|
2012-04-12 23:43:02 +02:00
|
|
|
rcfile=shorewallrc.cygwin
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -f /etc/debian_version ]; then
|
|
|
|
params[HOST]=debian
|
2015-08-01 20:23:35 +02:00
|
|
|
rcfile=shorewallrc.debian.sysvinit
|
2012-04-12 23:43:02 +02:00
|
|
|
elif [ -f /etc/redhat-release ]; then
|
|
|
|
params[HOST]=redhat
|
|
|
|
rcfile=shorewallrc.redhat
|
|
|
|
elif [ -f /etc/slackware-version ] ; then
|
|
|
|
params[HOST]=slackware
|
|
|
|
rcfile=shorewallrc.slackware
|
|
|
|
elif [ -f /etc/SuSE-release ]; then
|
|
|
|
params[HOST]=suse
|
|
|
|
rcfile=shorewallrc.suse
|
|
|
|
elif [ -f /etc/arch-release ] ; then
|
|
|
|
params[HOST]=archlinux
|
|
|
|
rcfile=shorewallrc.archlinux
|
|
|
|
else
|
|
|
|
params[HOST]=linux
|
|
|
|
rcfile=shorewallrc.default
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
vendor=${params[HOST]}
|
|
|
|
elif [ $vendor = linux ]; then
|
2012-06-05 21:52:12 +02:00
|
|
|
rcfile=shorewallrc.default;
|
2012-03-27 23:33:49 +02:00
|
|
|
else
|
|
|
|
rcfile=shorewallrc.$vendor
|
2012-04-12 23:43:02 +02:00
|
|
|
if [ ! -f $rcfile ]; then
|
|
|
|
echo "ERROR: $vendor is not a recognized host type" >&2
|
|
|
|
exit 1
|
2015-10-31 21:29:02 +01:00
|
|
|
elif [ $vendor = default ]; then
|
|
|
|
params[HOST]=linux
|
|
|
|
vendor=linux
|
2012-04-12 23:43:02 +02:00
|
|
|
fi
|
2012-03-27 23:33:49 +02:00
|
|
|
fi
|
|
|
|
|
2012-04-12 23:43:02 +02:00
|
|
|
if [ $vendor = linux ]; then
|
|
|
|
echo "INFO: Creating a generic Linux installation - " `date`;
|
|
|
|
else
|
|
|
|
echo "INFO: Creating a ${vendor}-specific installation - " `date`;
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
2012-03-27 23:33:49 +02:00
|
|
|
getfileparams < $rcfile || exit 1
|
|
|
|
|
|
|
|
for p in ${!params[@]}; do
|
|
|
|
options[${p}]="${params[${p}]}"
|
|
|
|
done
|
|
|
|
|
2012-04-12 23:43:02 +02:00
|
|
|
echo '#' > shorewallrc
|
|
|
|
echo "# Created by Shorewall Core version $VERSION configure - " `date` >> shorewallrc
|
|
|
|
echo '#' >> shorewallrc
|
|
|
|
|
2012-04-16 21:57:34 +02:00
|
|
|
if [ $# -gt 0 ]; then
|
2012-04-12 23:43:02 +02:00
|
|
|
echo "# Input: $@" >> shorewallrc
|
|
|
|
echo '#' >> shorewallrc
|
|
|
|
fi
|
2012-03-27 23:33:49 +02:00
|
|
|
|
2012-09-02 23:36:11 +02:00
|
|
|
if [ -n "${options[VARLIB]}" ]; then
|
|
|
|
if [ -z "${options[VARDIR]}" ]; then
|
|
|
|
options[VARDIR]='${VARLIB}/${PRODUCT}'
|
|
|
|
fi
|
|
|
|
elif [ -n "${options[VARDIR]}" ]; then
|
|
|
|
if [ -z "{$options[VARLIB]}" ]; then
|
|
|
|
options[VARLIB]=${options[VARDIR]}
|
|
|
|
options[VARDIR]='${VARLIB}/${PRODUCT}'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-10-13 20:56:26 +02:00
|
|
|
if [ -z "${options[SERVICEDIR]}" ]; then
|
2014-11-15 13:40:21 +01:00
|
|
|
options[SERVICEDIR]="${options[SYSTEMD]}"
|
2014-10-08 01:46:16 +02:00
|
|
|
fi
|
|
|
|
|
2012-03-27 23:33:49 +02:00
|
|
|
for on in \
|
2012-04-12 23:43:02 +02:00
|
|
|
HOST \
|
2012-03-27 23:33:49 +02:00
|
|
|
PREFIX \
|
|
|
|
SHAREDIR \
|
|
|
|
LIBEXECDIR \
|
|
|
|
PERLLIBDIR \
|
|
|
|
CONFDIR \
|
|
|
|
SBINDIR \
|
|
|
|
MANDIR \
|
|
|
|
INITDIR \
|
|
|
|
INITSOURCE \
|
|
|
|
INITFILE \
|
|
|
|
AUXINITSOURCE \
|
|
|
|
AUXINITFILE \
|
2014-10-13 20:56:26 +02:00
|
|
|
SERVICEDIR \
|
2013-08-18 23:27:26 +02:00
|
|
|
SERVICEFILE \
|
2012-04-01 19:47:24 +02:00
|
|
|
SYSCONFFILE \
|
2012-03-27 23:33:49 +02:00
|
|
|
SYSCONFDIR \
|
2012-05-15 20:32:35 +02:00
|
|
|
SPARSE \
|
2012-03-27 23:33:49 +02:00
|
|
|
ANNOTATED \
|
2012-09-02 23:36:11 +02:00
|
|
|
VARLIB \
|
2012-03-27 23:33:49 +02:00
|
|
|
VARDIR
|
|
|
|
do
|
2012-04-12 23:43:02 +02:00
|
|
|
echo "$on=${options[${on}]}"
|
2012-03-27 23:33:49 +02:00
|
|
|
echo "$on=${options[${on}]}" >> shorewallrc
|
|
|
|
done
|