Centralize setting of product-dependent g_* variables

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2016-11-19 17:17:03 -08:00
parent 9eb390403b
commit 137b051e52
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
6 changed files with 63 additions and 63 deletions

View File

@ -26,53 +26,62 @@
SHOREWALL_LIBVERSION=40509
[ -n "${g_program:=shorewall}" ]
setup_environment() {
g_basedir=${SHAREDIR}/shorewall
if [ -z "$g_readrc" ]; then
g_sharedir="$SHAREDIR"/$PRODUCT
g_confdir="$CONFDIR"/$PRODUCT
g_program=$PRODUCT
case $g_program in
shorewall)
g_product="Shorewall"
g_family=4
g_tool=iptables
g_lite=
;;
shorewall6)
g_product="Shorewall6"
g_family=6
g_tool=ip6tables
g_lite=
;;
shorewall-lite)
g_product="Shorewall Lite"
g_family=4
g_tool=iptables
g_lite=Yes
;;
shorewall6-lite)
g_product="Shorewall6 Lite"
g_family=6
g_tool=ip6tables
g_lite=Yes
;;
*)
echo " ERROR: Unknown PRODUCT ($PRODUCT)" >&2
exit 1
;;
esac
if [ -z "${VARLIB}" ]; then
VARLIB=${VARDIR}
VARDIR=${VARLIB}/$g_program
elif [ -z "${VARDIR}" ]; then
VARDIR="${VARLIB}/${PRODUCT}"
fi
}
if [ -z "$PRODUCT" ]; then
PRODUCT=shorewall
#
# This is modified by the installer when ${SHAREDIR} != /usr/share
#
. /usr/share/shorewall/shorewallrc
g_sharedir="$SHAREDIR"/$g_program
g_confdir="$CONFDIR"/$g_program
g_readrc=1
fi
g_basedir=${SHAREDIR}/shorewall
case $g_program in
shorewall)
g_product="Shorewall"
g_family=4
g_tool=iptables
g_lite=
;;
shorewall6)
g_product="Shorewall6"
g_family=6
g_tool=ip6tables
g_lite=
;;
shorewall-lite)
g_product="Shorewall Lite"
g_family=4
g_tool=iptables
g_lite=Yes
;;
shorewall6-lite)
g_product="Shorewall6 Lite"
g_family=6
g_tool=ip6tables
g_lite=Yes
;;
esac
if [ -z "${VARLIB}" ]; then
VARLIB=${VARDIR}
VARDIR=${VARLIB}/$g_program
elif [ -z "${VARDIR}" ]; then
VARDIR="${VARLIB}/${PRODUCT}"
setup_environment
fi
#

View File

@ -27,20 +27,17 @@
SHOREWALL_CAPVERSION=50004
[ -n "${g_program:=shorewall}" ]
if [ -z "$g_readrc" ]; then
#
# This is modified by the installer when ${SHAREDIR} <> /usr/share
#
. /usr/share/shorewall/shorewallrc
g_sharedir="$SHAREDIR"/$g_program
g_confdir="$CONFDIR"/$g_program
g_readrc=1
g_basedir=${SHAREDIR}/shorewall
fi
. ${SHAREDIR}/shorewall/lib.base
. ${g_basedir}/lib.base
#
# Issue an error message and die
@ -4370,8 +4367,6 @@ shorewall_cli() {
VERBOSE=
VERBOSITY=1
[ -n "$g_lite" ] || . ${g_basedir}/lib.cli-std
finished=0
while [ $finished -eq 0 ]; do
@ -4486,6 +4481,10 @@ shorewall_cli() {
usage 1
fi
setup_environment
[ -n "$g_lite" ] || . ${SHAREDIR}/shorewall/lib.cli-std
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
MUTEX_TIMEOUT=

View File

@ -32,11 +32,9 @@ PRODUCT=shorewall-lite
#
. /usr/share/shorewall/shorewallrc
g_program=$PRODUCT
g_sharedir="$SHAREDIR"/shorewall-lite
g_confdir="$CONFDIR"/shorewall-lite
g_readrc=1
g_basedir=${SHAREDIR}/shorewall
. ${SHAREDIR}/shorewall/lib.cli
. ${g_basedir}/lib.cli
shorewall_cli $@

View File

@ -32,11 +32,9 @@ PRODUCT=shorewall
#
. /usr/share/shorewall/shorewallrc
g_program=$PRODUCT
g_sharedir="$SHAREDIR"/shorewall
g_confdir="$CONFDIR"/shorewall
g_readrc=1
g_basedir=${SHAREDIR}/shorewall
. $g_sharedir/lib.cli
. ${g_basedir}/lib.cli
shorewall_cli $@

View File

@ -32,11 +32,9 @@ PRODUCT=shorewall6-lite
#
. /usr/share/shorewall/shorewallrc
g_program=$PRODUCT
g_sharedir="$SHAREDIR"/shorewall6-lite
g_confdir="$CONFDIR"/shorewall6-lite
g_basedir=${SHAREDIR}/shorewall
g_readrc=1
. ${SHAREDIR}/shorewall/lib.cli
. ${g_basedir}/lib.cli
shorewall_cli $@

View File

@ -32,11 +32,9 @@ PRODUCT=shorewall6
#
. /usr/share/shorewall/shorewallrc
g_program=$PRODUCT
g_sharedir="$SHAREDIR"/shorewall6
g_confdir="$CONFDIR"/shorewall6
g_readrc=1
g_basedir=${SHAREDIR}/shorewall
. ${SHAREDIR}/shorewall/lib.cli
. ${g_basedir}/lib.cli
shorewall_cli $@