From 089ff4eb33ab115475d5bcac38f2b399d262a1ff Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 18 Dec 2016 11:18:07 -0800 Subject: [PATCH] Establish default product based on $0 Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 2 +- Shorewall-core/lib.core | 38 +++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index af48f95a7..f6a95584d 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -4531,7 +4531,7 @@ shorewall_cli() { usage 1 fi - setup_product_environment 1 + setup_product_environment [ -n "$g_lite" ] || . ${SHAREDIR}/shorewall/lib.cli-std diff --git a/Shorewall-core/lib.core b/Shorewall-core/lib.core index 9313fc0cf..3fe64a5c3 100644 --- a/Shorewall-core/lib.core +++ b/Shorewall-core/lib.core @@ -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 #