Rename setup_environment to setup_product_environment

- Default to first detected product
- Verify that specified product is installed

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2016-11-20 08:48:18 -08:00
parent bb5c3a50f5
commit 36517cdb1e
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
5 changed files with 28 additions and 18 deletions

View File

@ -26,7 +26,16 @@
SHOREWALL_LIBVERSION=40509
setup_environment() {
#
# Fatal Error
#
fatal_error() # $@ = Message
{
echo " ERROR: $@" >&2
exit 2
}
setup_product_environment() {
g_basedir=${SHAREDIR}/shorewall
g_sharedir="$SHAREDIR"/$PRODUCT
@ -60,11 +69,12 @@ setup_environment() {
g_lite=Yes
;;
*)
echo " ERROR: Unknown PRODUCT ($PRODUCT)" >&2
exit 1
fatal_error "Unknown PRODUCT ($PRODUCT)"
;;
esac
[ -f ${SHAREDIR}/${PRODUCT}/version ] || fatal_error "$g_product does not appear to be installed on this system"
if [ -z "${VARLIB}" ]; then
VARLIB=${VARDIR}
VARDIR=${VARLIB}/$g_program
@ -74,7 +84,6 @@ setup_environment() {
}
if [ -z "$PRODUCT" ]; then
PRODUCT=shorewall
#
# This is modified by the installer when ${SHAREDIR} != /usr/share
#
@ -82,17 +91,18 @@ if [ -z "$PRODUCT" ]; then
g_basedir=${SHAREDIR}/shorewall
setup_environment
fi
if [ -f ${g_basedir}/version ]; then
PRODUCT=shorewall
elif [ -f ${SHAREDIR}/shorewall-lite/version ]; then
PRODUCT=shorewall-lite
elif [ -f ${SHAREDIR}/shorewall6-lite/version ]; then
PRODUCT=shorewall6-lite
else
fatal_error "No Shorewall firewall product is installed"
fi
#
# Fatal Error
#
fatal_error() # $@ = Message
{
echo " ERROR: $@" >&2
exit 2
}
setup_product_environment
fi
#
# Not configured Error

View File

@ -4495,7 +4495,7 @@ shorewall_cli() {
usage 1
fi
setup_environment
setup_product_environment
[ -n "$g_lite" ] || . ${SHAREDIR}/shorewall/lib.cli-std

View File

@ -56,7 +56,7 @@ g_basedir=${SHAREDIR}/shorewall
. ${SHAREDIR}/shorewall/lib.cli
setup_environment
setup_product_environment
. ${SHAREDIR}/shorewall-lite/configpath

View File

@ -42,7 +42,7 @@ g_basedir=${SHAREDIR}/shorewall
. $g_basedir/lib.cli
setup_environment
setup_product_environment
CONFIG_PATH="$2"

View File

@ -55,7 +55,7 @@ g_basedir=${SHAREDIR}/shorewall
. ${SHAREDIR}/shorewall/lib.cli
setup_environment
setup_product_environment
. ${SHAREDIR}/shorewall-lite/configpath