From 08edd066c83d25ef5f410466292fa6a5475d50e6 Mon Sep 17 00:00:00 2001 From: teastep Date: Wed, 29 Nov 2006 01:11:29 +0000 Subject: [PATCH] Move 'logwatch' processing to lib.cli git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5020 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall-lite/shorewall-lite | 53 +------------------------------- Shorewall/lib.cli | 57 +++++++++++++++++++++++++++++++++++ Shorewall/shorewall | 56 ++-------------------------------- 3 files changed, 60 insertions(+), 106 deletions(-) diff --git a/Shorewall-lite/shorewall-lite b/Shorewall-lite/shorewall-lite index 178aa7602..8c185fcbf 100755 --- a/Shorewall-lite/shorewall-lite +++ b/Shorewall-lite/shorewall-lite @@ -640,58 +640,7 @@ case "$COMMAND" in echo $version Lite ;; logwatch) - shift - - finished=0 - - while [ $finished -eq 0 -a $# -ne 0 ]; do - option=$1 - case $option in - -*) - option=${option#-} - - [ -z "$option" ] && usage 1 - - while [ -n "$option" ]; do - case $option in - v*) - VERBOSE=$(($VERBOSE + 1 )) - option=${option#v} - ;; - q*) - VERBOSE=$(($VERBOSE - 1 )) - option=${option#q} - ;; - m*) - SHOWMACS=Yes - option=${option#m} - ;; - -) - finished=1 - option= - ;; - *) - usage 1 - ;; - esac - done - shift - ;; - *) - finished=1 - ;; - esac - done - - [ -n "$debugging" ] && set -x - - if [ $# -eq 1 ]; then - logwatch $1 - elif [ $# -eq 0 ]; then - logwatch 30 - else - usage 1 - fi + logwatch_command $@ ;; drop) [ -n "$debugging" ] && set -x diff --git a/Shorewall/lib.cli b/Shorewall/lib.cli index f12e78657..5b3daf584 100644 --- a/Shorewall/lib.cli +++ b/Shorewall/lib.cli @@ -930,3 +930,60 @@ allow_command() { exit 2 fi } +# +# 'logwatch' command executor +# +logwatch_command() { + shift + + finished=0 + + while [ $finished -eq 0 -a $# -ne 0 ]; do + option=$1 + case $option in + -*) + option=${option#-} + + [ -z "$option" ] && usage 1 + + while [ -n "$option" ]; do + case $option in + v*) + VERBOSE=$(($VERBOSE + 1 )) + option=${option#v} + ;; + q*) + VERBOSE=$(($VERBOSE - 1 )) + option=${option#q} + ;; + m*) + SHOWMACS=Yes + option=${option#m} + ;; + -) + finished=1 + option= + ;; + *) + usage 1 + ;; + esac + done + shift + ;; + *) + finished=1 + ;; + esac + done + + [ -n "$debugging" ] && set -x + + if [ $# -eq 1 ]; then + logwatch $1 + elif [ $# -eq 0 ]; then + logwatch 30 + else + usage 1 + fi +} diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 53ef99df8..b73c6ed3e 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -1209,64 +1209,12 @@ case "$COMMAND" in fi elif ! $IPTABLES -L shorewall > /dev/null 2> /dev/null; then $0 $VERBOSE $NOROUTES start - elif [ $# -eq 3 ]; then - sleep $3 + elif [ $# -eq 3 ]; the sleep $3 $0 $VERBOSE $NOROUTES restart fi ;; logwatch) - shift - - finished=0 - - while [ $finished -eq 0 -a $# -ne 0 ]; do - option=$1 - case $option in - -*) - option=${option#-} - - [ -z "$option" ] && usage 1 - - while [ -n "$option" ]; do - case $option in - v*) - VERBOSE=$(($VERBOSE + 1 )) - option=${option#v} - ;; - q*) - VERBOSE=$(($VERBOSE - 1 )) - option=${option#q} - ;; - m*) - SHOWMACS=Yes - option=${option#m} - ;; - -) - finished=1 - option= - ;; - *) - usage 1 - ;; - esac - done - shift - ;; - *) - finished=1 - ;; - esac - done - - [ -n "$debugging" ] && set -x - - if [ $# -eq 1 ]; then - logwatch $1 - elif [ $# -eq 0 ]; then - logwatch 30 - else - usage 1 - fi + logwatch_command $@ ;; drop) [ -n "$debugging" ] && set -x