From 90d254f0c396e4bfbd5f6004e2e7c44aa912ae2a Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Wed, 2 Mar 2016 08:32:49 -0800 Subject: [PATCH] Add PAGER option Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 26 +++++++++---------- Shorewall/Perl/Shorewall/Config.pm | 1 + Shorewall/Samples/Universal/shorewall.conf | 6 +++++ .../Samples/one-interface/shorewall.conf | 6 +++++ .../Samples/three-interfaces/shorewall.conf | 6 +++++ .../Samples/two-interfaces/shorewall.conf | 6 +++++ Shorewall/configfiles/shorewall.conf | 6 +++++ Shorewall/lib.cli-std | 15 +++++++++++ Shorewall/manpages/shorewall.conf.xml | 13 ++++++++++ Shorewall6/Samples6/Universal/shorewall6.conf | 6 +++++ .../Samples6/one-interface/shorewall6.conf | 6 +++++ .../Samples6/three-interfaces/shorewall6.conf | 6 +++++ .../Samples6/two-interfaces/shorewall6.conf | 6 +++++ Shorewall6/configfiles/shorewall6.conf | 6 +++++ Shorewall6/manpages/shorewall6.conf.xml | 13 ++++++++++ 15 files changed, 115 insertions(+), 13 deletions(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index 66a4c0af1..e8c6030a4 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -3728,6 +3728,19 @@ get_config() { g_loopback=$(find_loopback_interfaces) + if [ -n "$PAGER" -a -t 1 ]; then + case $PAGER in + /*) + g_pager="$PAGER" + [ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" + ;; + *) + g_pager=$(mywhich pager 2> /dev/null) + [ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" + ;; + esac + fi + lib=$(find_file lib.cli-user) [ -f $lib ] && . $lib @@ -4223,19 +4236,6 @@ shorewall_cli() { ;; esac - if [ -t 1 ]; then - # - # Output is to a terminal -- use a pager on commands with verbose output - # - if qt mywhich less; then - g_pager='| less' - elif qt mywhich more; then - g_pager='| more' - else - g_pager='' - fi - fi - COMMAND=$1 case "$COMMAND" in diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index cad326877..747e381d2 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -4912,6 +4912,7 @@ sub update_config_file( $ ) { update_default( 'USE_DEFAULT_RT', 'No' ); update_default( 'EXPORTMODULES', 'No' ); update_default( 'RESTART', 'reload' ); + update_default( 'PAGER', '' ); my $fn; diff --git a/Shorewall/Samples/Universal/shorewall.conf b/Shorewall/Samples/Universal/shorewall.conf index f32ff204d..216fcdeec 100644 --- a/Shorewall/Samples/Universal/shorewall.conf +++ b/Shorewall/Samples/Universal/shorewall.conf @@ -17,6 +17,12 @@ STARTUP_ENABLED=Yes VERBOSITY=1 +############################################################################### +# P A G E R +############################################################################### + +PAGER=more + ############################################################################### # L O G G I N G ############################################################################### diff --git a/Shorewall/Samples/one-interface/shorewall.conf b/Shorewall/Samples/one-interface/shorewall.conf index ac80e41a5..f6ae78852 100644 --- a/Shorewall/Samples/one-interface/shorewall.conf +++ b/Shorewall/Samples/one-interface/shorewall.conf @@ -28,6 +28,12 @@ STARTUP_ENABLED=No VERBOSITY=1 +############################################################################### +# P A G E R +############################################################################### + +PAGER=more + ############################################################################### # L O G G I N G ############################################################################### diff --git a/Shorewall/Samples/three-interfaces/shorewall.conf b/Shorewall/Samples/three-interfaces/shorewall.conf index 4d5492ef8..bc204a7d0 100644 --- a/Shorewall/Samples/three-interfaces/shorewall.conf +++ b/Shorewall/Samples/three-interfaces/shorewall.conf @@ -25,6 +25,12 @@ STARTUP_ENABLED=No VERBOSITY=1 +############################################################################### +# P A G E R +############################################################################### + +PAGER=more + ############################################################################### # L O G G I N G ############################################################################### diff --git a/Shorewall/Samples/two-interfaces/shorewall.conf b/Shorewall/Samples/two-interfaces/shorewall.conf index c06e403e9..1e930d405 100644 --- a/Shorewall/Samples/two-interfaces/shorewall.conf +++ b/Shorewall/Samples/two-interfaces/shorewall.conf @@ -28,6 +28,12 @@ STARTUP_ENABLED=No VERBOSITY=1 +############################################################################### +# P A G E R +############################################################################### + +PAGER=more + ############################################################################### # L O G G I N G ############################################################################### diff --git a/Shorewall/configfiles/shorewall.conf b/Shorewall/configfiles/shorewall.conf index 7d4386a2b..d38d741bb 100644 --- a/Shorewall/configfiles/shorewall.conf +++ b/Shorewall/configfiles/shorewall.conf @@ -17,6 +17,12 @@ STARTUP_ENABLED=No VERBOSITY=1 +############################################################################### +# P A G E R +############################################################################### + +PAGER=more + ############################################################################### # L O G G I N G ############################################################################### diff --git a/Shorewall/lib.cli-std b/Shorewall/lib.cli-std index ffafebc35..c7683f21f 100644 --- a/Shorewall/lib.cli-std +++ b/Shorewall/lib.cli-std @@ -316,6 +316,21 @@ get_config() { g_loopback=$(find_loopback_interfaces) + if [ -n "$PAGER" -a -t 1 ]; then + case $PAGER in + /*) + g_pager="$PAGER" + [ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist" + ;; + *) + g_pager=$(mywhich pager 2> /dev/null) + [ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found" + ;; + esac + + [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" + fi + lib=$(find_file lib.cli-user) [ -f $lib ] && . $lib diff --git a/Shorewall/manpages/shorewall.conf.xml b/Shorewall/manpages/shorewall.conf.xml index eb375662d..31c318574 100644 --- a/Shorewall/manpages/shorewall.conf.xml +++ b/Shorewall/manpages/shorewall.conf.xml @@ -1952,6 +1952,19 @@ LOG:info:,bar net fw + + PAGER=pathname + + + Added in Shorewall 5.0.6. Specifies a path name of a pager + program like less or more. + When PAGER is given, the output of verbose status + commands and the dump command are piped through + the named program when the output file is a terminal. + + + PATH=pathname[ + + PAGER=pathname + + + Added in Shorewall 5.0.6. Specifies a path name of a pager + program like less or more. + When PAGER is given, the output of verbose status + commands and the dump command are piped through + the named program when the output file is a terminal. + + + PATH=pathname[