2012-03-27 23:33:49 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2018-06-23 17:29:01 +02:00
|
|
|
# Shorewall Packet Filtering Firewall configuration program - V5.2
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
2018-01-08 00:01:46 +01:00
|
|
|
# (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net)
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
2020-03-26 22:58:35 +01:00
|
|
|
# Shorewall documentation is available at https://shorewall.org
|
2012-03-27 23:33:49 +02:00
|
|
|
#
|
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
|
|
|
|
|
2015-12-05 17:31:22 +01:00
|
|
|
cd $(dirname $0)
|
|
|
|
|
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-11-29 18:06:39 +01:00
|
|
|
vendor=debian
|
2013-08-09 02:44:40 +02:00
|
|
|
;;
|
|
|
|
opensuse)
|
|
|
|
vendor=suse
|
|
|
|
;;
|
2018-05-29 17:13:26 +02:00
|
|
|
alt|basealt|altlinux)
|
|
|
|
vendor=alt
|
|
|
|
;;
|
2013-08-09 02:44:40 +02:00
|
|
|
*)
|
|
|
|
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
|
|
|
|
;;
|
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-11-29 18:06:39 +01:00
|
|
|
ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
|
2018-05-29 17:13:26 +02:00
|
|
|
elif [ -f /etc/altlinux-release ] ; then
|
|
|
|
params[HOST]=alt
|
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
|
2015-11-07 16:20:44 +01:00
|
|
|
elif [ -f /etc/openwrt_release ]; then
|
|
|
|
params[HOST]=openwrt
|
|
|
|
rcfile=shorewallrc.openwrt
|
2012-04-12 23:43:02 +02:00
|
|
|
else
|
|
|
|
params[HOST]=linux
|
|
|
|
rcfile=shorewallrc.default
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
vendor=${params[HOST]}
|
2012-03-27 23:33:49 +02:00
|
|
|
else
|
2015-11-29 18:06:39 +01:00
|
|
|
if [ $vendor = linux ]; then
|
|
|
|
rcfile=shorewallrc.default;
|
|
|
|
elif [ $vendor = debian -a -f /etc/debian_version ]; then
|
|
|
|
ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
|
|
|
|
else
|
|
|
|
rcfile=shorewallrc.$vendor
|
|
|
|
fi
|
|
|
|
|
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
|
2015-12-12 17:10:34 +01:00
|
|
|
elif [[ $vendor == debian.* ]]; then
|
|
|
|
params[HOST]=debian
|
|
|
|
vendor=debian
|
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
|
2015-12-06 21:04:34 +01:00
|
|
|
echo "INFO: Creating a ${params[HOST]}-specific installation - " `date`;
|
2012-04-12 23:43:02 +02:00
|
|
|
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
|
2017-07-20 23:19:39 +02:00
|
|
|
echo "# Created by Shorewall Core version $VERSION configure - " `date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}"` >> shorewallrc
|
2015-11-29 18:06:39 +01:00
|
|
|
echo "# rc file: $rcfile" >> shorewallrc
|
2012-04-12 23:43:02 +02:00
|
|
|
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 \
|
2016-09-21 19:20:48 +02:00
|
|
|
VARDIR \
|
2017-07-20 21:23:59 +02:00
|
|
|
DEFAULT_PAGER
|
2012-03-27 23:33:49 +02:00
|
|
|
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
|