mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-21 05:41:07 +01:00
6f81bb5c8e
The previous syntax resulted in: ./configure: line 199: [SERVICEDIR]=: command not found Signed-off-by: Evangelos Foutras <evangelos@foutrelis.com> Signed-off-by: Tom Eastep <teastep@shorewall.net>
228 lines
4.5 KiB
Bash
Executable File
228 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Shorewall Packet Filtering Firewall RPM configuration program - V4.6
|
|
#
|
|
# (c) 2012,2014 - Tom Eastep (teastep@shorewall.net)
|
|
#
|
|
# Shorewall documentation is available at http://www.shorewall.net
|
|
#
|
|
# 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.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Usage: ./configure [ <option>=<setting> ] ...
|
|
#
|
|
#
|
|
################################################################################################
|
|
#
|
|
# 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
|
|
|
|
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
|
|
|
|
return 0
|
|
}
|
|
|
|
for p in $@; do
|
|
|
|
if [ -n "${p}" ]; then
|
|
declare -u pn
|
|
|
|
pn=${p%=*}
|
|
pn=${pn#--}
|
|
pv=${p#*=}
|
|
|
|
if [ -n "${pn}" ]; then
|
|
|
|
case ${pn} in
|
|
VENDOR)
|
|
pn=HOST
|
|
;;
|
|
SHAREDSTATEDIR)
|
|
pn=VARLIB
|
|
;;
|
|
DATADIR)
|
|
pn=SHAREDIR
|
|
;;
|
|
esac
|
|
|
|
params[${pn}]="${pv}"
|
|
else
|
|
echo "ERROR: Invalid option ($p)" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
vendor=${params[HOST]}
|
|
|
|
if [ -z "$vendor" ]; then
|
|
if [ -f /etc/os-release ]; then
|
|
eval $(cat /etc/os-release | grep ^ID=)
|
|
|
|
case $ID in
|
|
fedora|rhel)
|
|
vendor=redhat
|
|
;;
|
|
debian|ubuntu)
|
|
vendor=debian
|
|
;;
|
|
opensuse)
|
|
vendor=suse
|
|
;;
|
|
*)
|
|
vendor="$ID"
|
|
;;
|
|
esac
|
|
|
|
params[HOST]="$vendor"
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$vendor" ]; then
|
|
case `uname` in
|
|
Darwin)
|
|
params[HOST]=apple
|
|
rcfile=shorewallrc.apple
|
|
;;
|
|
|
|
cygwin*|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
|
|
rcfile=shorewallrc.default;
|
|
else
|
|
rcfile=shorewallrc.$vendor
|
|
if [ ! -f $rcfile ]; then
|
|
echo "ERROR: $vendor is not a recognized host type" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ $vendor = linux ]; then
|
|
echo "INFO: Creating a generic Linux installation - " `date`;
|
|
else
|
|
echo "INFO: Creating a ${vendor}-specific installation - " `date`;
|
|
fi
|
|
|
|
echo
|
|
|
|
getfileparams < $rcfile || exit 1
|
|
|
|
for p in ${!params[@]}; do
|
|
options[${p}]="${params[${p}]}"
|
|
done
|
|
|
|
echo '#' > shorewallrc
|
|
echo "# Created by Shorewall Core version $VERSION configure - " `date` >> shorewallrc
|
|
echo '#' >> shorewallrc
|
|
|
|
if [ $# -gt 0 ]; then
|
|
echo "# Input: $@" >> shorewallrc
|
|
echo '#' >> shorewallrc
|
|
fi
|
|
|
|
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
|
|
|
|
if [ -z "${options[SERVICEDIR]}" ]; then
|
|
options[SERVICEDIR]="${options[SYSTEMD]}"
|
|
fi
|
|
|
|
for on in \
|
|
HOST \
|
|
PREFIX \
|
|
SHAREDIR \
|
|
LIBEXECDIR \
|
|
PERLLIBDIR \
|
|
CONFDIR \
|
|
SBINDIR \
|
|
MANDIR \
|
|
INITDIR \
|
|
INITSOURCE \
|
|
INITFILE \
|
|
AUXINITSOURCE \
|
|
AUXINITFILE \
|
|
SERVICEDIR \
|
|
SERVICEFILE \
|
|
SYSCONFFILE \
|
|
SYSCONFDIR \
|
|
SPARSE \
|
|
ANNOTATED \
|
|
VARLIB \
|
|
VARDIR
|
|
do
|
|
echo "$on=${options[${on}]}"
|
|
echo "$on=${options[${on}]}" >> shorewallrc
|
|
done
|