2012-03-27 23:33:49 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Shorewall Packet Filtering Firewall RPM configuration program - V4.5
|
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
|
|
|
#
|
|
|
|
# (c) 2012 - Tom Eastep (teastep@shorewall.net)
|
|
|
|
#
|
|
|
|
# Shorewall documentation is available at http://www.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.
|
|
|
|
#
|
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
|
|
|
|
#
|
|
|
|
VERSION=4.5.2.1
|
|
|
|
|
|
|
|
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
|
|
|
|
eval $(cat /etc/os-release | grep ^ID)
|
|
|
|
|
|
|
|
case $ID in
|
|
|
|
fedora)
|
|
|
|
vendor=redhat
|
|
|
|
;;
|
|
|
|
debian)
|
|
|
|
vendor=debian
|
|
|
|
;;
|
|
|
|
opensuse)
|
|
|
|
vendor=suse
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
vendor="$ID"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
$params[HOST]="
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "vendor" ]; then
|
2012-04-12 23:43:02 +02:00
|
|
|
case `uname` in
|
|
|
|
Darwin)
|
|
|
|
$params[HOST]=apple
|
|
|
|
rcfile=shorewallrc.apple
|
|
|
|
;;
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2012-04-12 23:43:02 +02:00
|
|
|
cygwin*)
|
|
|
|
$params[HOST]=cygwin
|
|
|
|
rcfile=shorewallrc.cygwin
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -f /etc/debian_version ]; then
|
|
|
|
params[HOST]=debian
|
|
|
|
rcfile=shorewallrc.debian
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
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 \
|
|
|
|
SYSTEMD \
|
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
|