Eliminate running the script twice is some cases

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2015-06-26 14:32:43 -07:00
parent 846d629c47
commit 9f08726794
4 changed files with 17 additions and 6 deletions

View File

@ -4019,6 +4019,7 @@ shorewall_cli() {
g_tcrules= g_tcrules=
g_counters= g_counters=
g_loopback= g_loopback=
g_compiled=
VERBOSE= VERBOSE=
VERBOSITY=1 VERBOSITY=1

View File

@ -98,14 +98,22 @@ get_script_version() { # $1 = script
local digits local digits
local verbosity local verbosity
if [ "$g_compiled" = "$g_file" ]; then
#
# Either this script was just compiled or AUTOMAKE determined that compilation wasn't needed
#
temp="$VERSION"
else
verbosity="$VERBOSITY" verbosity="$VERBOSITY"
VERBOSITY=0 VERBOSITY=0
temp=$( $SHOREWALL_SHELL $1 version | tail -n 1 | sed 's/-.*//' ) temp=$( $SHOREWALL_SHELL $1 version | tail -n 1 )
fi
if [ -z "$temp" ]; then if [ -z "$temp" ]; then
version=0 version=0
else else
temp=${temp%-*}
ifs=$IFS ifs=$IFS
IFS=. IFS=.
temp=$(echo $temp) temp=$(echo $temp)

View File

@ -100,6 +100,8 @@ g_sha1sum2=
# Other Globals # Other Globals
# #
g_counters= g_counters=
g_compiled=
g_file=
initialize initialize

View File

@ -430,6 +430,7 @@ compiler() {
if [ -n "$g_conditional" ] && uptodate "$g_file"; then if [ -n "$g_conditional" ] && uptodate "$g_file"; then
echo "$g_file is up to date -- no compilation required" echo "$g_file is up to date -- no compilation required"
g_compiled="$g_file"
return 0 return 0
fi fi
@ -472,7 +473,8 @@ compiler() {
status=$? status=$?
if [ $status -eq 0 -a $COMMAND != check ]; then if [ $status -eq 0 -a $COMMAND != check ]; then
run_postcompile "$g_file" g_compiled="$g_file"
run_postcompile "$g_compiled"
return return
fi fi
@ -1227,8 +1229,6 @@ safe_commands() {
exit $status exit $status
fi fi
run_postcompile ${VARDIR}/.$command
case $command in case $command in
start) start)
RESTOREFILE=NONE RESTOREFILE=NONE