From b8f806e625636405dedc00818c4163dcfc21b42a Mon Sep 17 00:00:00 2001 From: teastep Date: Sun, 10 Nov 2002 23:15:53 +0000 Subject: [PATCH] Accomodate bash clones like dash and ash git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@325 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/firewall | 3 +- Shorewall/shorewall | 119 +++++++++++++++++++++++++++++++------------- 2 files changed, 86 insertions(+), 36 deletions(-) diff --git a/Shorewall/firewall b/Shorewall/firewall index 65079cf5f..275d3d1a9 100755 --- a/Shorewall/firewall +++ b/Shorewall/firewall @@ -4308,7 +4308,8 @@ case "$command" in status) [ $# -ne 1 ] && usage - echo -e "Shorewall-$version Status at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Status at $HOSTNAME - `date`" + echo iptables -L -n -v ;; diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 67741839f..abad834d0 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -150,8 +150,10 @@ display_chains() iptables -L -n -v > /tmp/chains-$$ clear - echo -e "$banner `date`\\n" - echo -e "Standard Chains\\n" + echo "$banner `date`" + echo + echo "Standard Chains" + echo firstchain="Yes" showchain INPUT showchain OUTPUT @@ -160,9 +162,11 @@ display_chains() timed_read clear - echo -e "$banner `date`\\n" + echo "$banner `date`" + echo firstchain=Yes - echo -e "Input Chains\\n" + echo "Input Chains" + echo chains=`grep '^Chain.*_[in|fwd]' /tmp/chains-$$ | cut -d' ' -f 2` @@ -176,10 +180,12 @@ display_chains() if [ -n "`grep "^Chain \.*${zone}" /tmp/chains-$$`" ] ; then clear - echo -e "$banner `date`\\n" + echo "$banner `date`" + echo firstchain=Yes eval display=\$${zone}_display - echo -e "$display Chains\\n" + echo "$display Chains" + echo for zone1 in $FW $zones; do showchain ${zone}2$zone1 showchain @${zone}2$zone1 @@ -193,9 +199,11 @@ display_chains() done clear - echo -e "$banner `date`\\n" + echo "$banner `date`" + echo firstchain=Yes - echo -e "Policy Chains\\n" + echo "Policy Chains" + echo showchain common showchain badpkt showchain icmpdef @@ -212,9 +220,11 @@ display_chains() timed_read clear - echo -e "$banner `date`\\n" + echo "$banner `date`" + echo firstchain=Yes - echo -e "Dynamic Chain\\n" + echo "Dynamic Chain" + echo showchain dynamic timed_read @@ -309,9 +319,11 @@ monitor_firewall() # $1 = timeout -- if negative, prompt each time that display_chains clear - echo -e "$banner `date`\\n" + echo "$banner `date`" + echo - echo -e "Dropped/Rejected Packet Log\\n" + echo "Dropped/Rejected Packet Log" + echo show_reset @@ -319,11 +331,18 @@ monitor_firewall() # $1 = timeout -- if negative, prompt each time that if [ "$rejects" != "$oldrejects" ]; then oldrejects="$rejects" - echo -e '\a' + + if [ -n "$BASH_VERSION" ]; then + echo -e '\a' + else + echo '\a' + fi + packet_log 20 if [ "$pause" = "Yes" ]; then - echo -en '\nEnter any character to continue: ' + echo + echo -n 'Enter any character to continue: ' read foo else timed_read @@ -335,26 +354,37 @@ monitor_firewall() # $1 = timeout -- if negative, prompt each time that fi clear - echo -e "$banner `date`\\n" - echo -e "NAT Status\\n" + echo "$banner `date`" + echo + echo "NAT Status" + echo iptables -t nat -L -n -v timed_read clear - echo -e "$banner `date`\\n" - echo -e "\\nTOS/MARK Status\\n" + echo "$banner `date`" + echo + echo + echo "TOS/MARK Status" + echo iptables -t mangle -L -n -v timed_read clear - echo -e "$banner `date`\\n" - echo -e "\\nTracked Connections\\n" + echo "$banner `date`" + echo + echo + echo "Tracked Connections" + echo cat /proc/net/ip_conntrack timed_read clear - echo -e "$banner `date`\\n" - echo -e "\\nTraffic Shaping/Control\\n" + echo "$banner `date`" + echo + echo + echo "Traffic Shaping/Control" + echo show_tc timed_read done @@ -383,9 +413,11 @@ logwatch() # $1 = timeout -- if negative, prompt each time that while true; do clear - echo -e "$banner `date`\\n" + echo "$banner `date`" + echo - echo -e "Dropped/Rejected Packet Log\\n" + echo "Dropped/Rejected Packet Log" + echo show_reset @@ -393,11 +425,18 @@ logwatch() # $1 = timeout -- if negative, prompt each time that if [ "$rejects" != "$oldrejects" ]; then oldrejects="$rejects" - echo -e '\a' + + if [ -n "$BASH_VERSION" ]; then + echo -e '\a' + else + echo '\a' + fi + packet_log 40 if [ "$pause" = "Yes" ]; then - echo -en '\nEnter any character to continue: ' + echo + echo -n 'Enter any character to continue: ' read foo else timed_read @@ -445,7 +484,8 @@ usage() # $1 = exit status # show_reset() { [ -f $STATEDIR/restarted ] && \ - echo -e "Counters reset `cat $STATEDIR/restarted`\\n" + echo "Counters reset `cat $STATEDIR/restarted`" && \ + echo } # @@ -550,32 +590,38 @@ case "$1" in [ $# -gt 2 ] && usage 1 case "$2" in connections) - echo -e "Shorewall-$version Connections at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Connections at $HOSTNAME - `date`" + echo cat /proc/net/ip_conntrack ;; nat) - echo -e "Shorewall-$version NAT at $HOSTNAME - `date`\\n" + echo "Shorewall-$version NAT at $HOSTNAME - `date`" + echo show_reset iptables -t nat -L -n -v ;; tos|mangle) - echo -e "Shorewall-$version TOS at $HOSTNAME - `date`\\n" + echo "Shorewall-$version TOS at $HOSTNAME - `date`" + echo show_reset iptables -t mangle -L -n -v ;; log) get_config - echo -e "Shorewall-$version Log at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Log at $HOSTNAME - `date`" + echo show_reset host=`echo $HOSTNAME | sed 's/\..*$//'` packet_log 20 ;; tc) - echo -e "Shorewall-$version Traffic Control at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Traffic Control at $HOSTNAME - `date`" + echo show_tc ;; *) - echo -e "Shorewall-$version Chain $2 at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Chain $2 at $HOSTNAME - `date`" + echo show_reset iptables -L $2 -n -v ;; @@ -594,7 +640,8 @@ case "$1" in [ $# -eq 1 ] || usage 1 get_config clear - echo -e "Shorewall-$version Status at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Status at $HOSTNAME - `date`" + echo show_reset host=`echo $HOSTNAME | sed 's/\..*$//'` iptables -L -n -v @@ -611,7 +658,9 @@ case "$1" in [ $# -eq 1 ] || usage 1 get_config clear - echo -e "Shorewall-$version Hits at $HOSTNAME - `date`\\n" + echo "Shorewall-$version Hits at $HOSTNAME - `date`" + echo + timeout=30 if [ `grep -c "Shorewall:" $LOGFILE ` -gt 0 ] ; then