From 2a40012fc4944ed903394a1c880d80fdc9769f01 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Wed, 27 Apr 2016 16:25:21 -0700 Subject: [PATCH] Include compile time and date in the output of 'shorewall status' Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 13 ++++++++++++- Shorewall/Perl/Shorewall/Compiler.pm | 15 +++++++++++++++ Shorewall/Perl/prog.footer | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index c5a6f01aa..83af6e967 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -3324,6 +3324,8 @@ report_capabilities1() { } show_status() { + local compiletime + if product_is_started ; then [ $VERBOSITY -ge 1 ] && echo "$g_product is running" status=0 @@ -3345,7 +3347,16 @@ show_status() { if [ $VERBOSITY -ge 1 ]; then if [ -f $g_firewall ]; then - state="$state ($g_firewall compiled by Shorewall version $($g_firewall version))" + compiletime=$($g_firewall date) + + case $compiletime in + Usage*) + state="$state ($g_firewall compiled by Shorewall version $($g_firewall version))" + ;; + *) + state="$state ($g_firewall compiled $compiletime by Shorewall version $($g_firewall version))" + ;; + esac fi echo "State:$state" echo diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index 2f45842be..7da9b60c4 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -596,6 +596,17 @@ EOF } +# +# Generate date_command() +# +sub compile_date_command() { + my $date = localtime; + + emit( "\ndate_command() {" , + " echo $date" , + "}" ); +} + # # The Compiler. # @@ -922,6 +933,10 @@ sub compiler { # compile_updown; # + # Echo the compilation time and date + # + compile_date_command; + # # Copy the footer to the script # copy $globals{SHAREDIRPL} . 'prog.footer' unless $test; diff --git a/Shorewall/Perl/prog.footer b/Shorewall/Perl/prog.footer index 0220b5f43..287cf9460 100644 --- a/Shorewall/Perl/prog.footer +++ b/Shorewall/Perl/prog.footer @@ -25,6 +25,7 @@ usage() { echo " savesets " echo " call [ ... ]" echo " version" + echo " date" echo echo "Options are:" echo @@ -469,6 +470,10 @@ case "$COMMAND" in echo $SHOREWALL_VERSION status=0 ;; + date) + [ $# -ne 1 ] && usage 2 + date_command + ;; help) [ $# -ne 1 ] && usage 2 usage 0