Establish default product based on $0

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2016-12-18 11:18:07 -08:00
parent 7ce5c31c68
commit 089ff4eb33
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
2 changed files with 28 additions and 12 deletions

View File

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

View File

@ -35,7 +35,7 @@ fatal_error() # $@ = Message
exit 2
}
setup_product_environment() { # $1 -- if non-empty, source shorewallrc
setup_product_environment() {
g_basedir=${SHAREDIR}/shorewall
g_sharedir="$SHAREDIR"/$PRODUCT
@ -88,16 +88,32 @@ setup_product_environment() { # $1 -- if non-empty, source shorewallrc
}
set_default_product() {
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
}
case $(basename $0) in
shorewall6)
PRODUCT=shorewall6
;;
shorewall4)
PRODUCT=shorewall
;;
shorewall-lite)
PRODUCT=shorewall-lite
;;
shorewall6-lite)
PRODUCT=shorewall6-lite
;;
*)
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
;;
esac
}
# Not configured Error
#