Accomodate bash clones like dash and ash

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@325 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2002-11-10 23:15:53 +00:00
parent 8c3af56566
commit b8f806e625
2 changed files with 86 additions and 36 deletions

View File

@ -4308,7 +4308,8 @@ case "$command" in
status) status)
[ $# -ne 1 ] && usage [ $# -ne 1 ] && usage
echo -e "Shorewall-$version Status at $HOSTNAME - `date`\\n" echo "Shorewall-$version Status at $HOSTNAME - `date`"
echo
iptables -L -n -v iptables -L -n -v
;; ;;

View File

@ -150,8 +150,10 @@ display_chains()
iptables -L -n -v > /tmp/chains-$$ iptables -L -n -v > /tmp/chains-$$
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo -e "Standard Chains\\n" echo
echo "Standard Chains"
echo
firstchain="Yes" firstchain="Yes"
showchain INPUT showchain INPUT
showchain OUTPUT showchain OUTPUT
@ -160,9 +162,11 @@ display_chains()
timed_read timed_read
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo
firstchain=Yes firstchain=Yes
echo -e "Input Chains\\n" echo "Input Chains"
echo
chains=`grep '^Chain.*_[in|fwd]' /tmp/chains-$$ | cut -d' ' -f 2` 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 if [ -n "`grep "^Chain \.*${zone}" /tmp/chains-$$`" ] ; then
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo
firstchain=Yes firstchain=Yes
eval display=\$${zone}_display eval display=\$${zone}_display
echo -e "$display Chains\\n" echo "$display Chains"
echo
for zone1 in $FW $zones; do for zone1 in $FW $zones; do
showchain ${zone}2$zone1 showchain ${zone}2$zone1
showchain @${zone}2$zone1 showchain @${zone}2$zone1
@ -193,9 +199,11 @@ display_chains()
done done
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo
firstchain=Yes firstchain=Yes
echo -e "Policy Chains\\n" echo "Policy Chains"
echo
showchain common showchain common
showchain badpkt showchain badpkt
showchain icmpdef showchain icmpdef
@ -212,9 +220,11 @@ display_chains()
timed_read timed_read
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo
firstchain=Yes firstchain=Yes
echo -e "Dynamic Chain\\n" echo "Dynamic Chain"
echo
showchain dynamic showchain dynamic
timed_read timed_read
@ -309,9 +319,11 @@ monitor_firewall() # $1 = timeout -- if negative, prompt each time that
display_chains display_chains
clear 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 show_reset
@ -319,11 +331,18 @@ monitor_firewall() # $1 = timeout -- if negative, prompt each time that
if [ "$rejects" != "$oldrejects" ]; then if [ "$rejects" != "$oldrejects" ]; then
oldrejects="$rejects" oldrejects="$rejects"
echo -e '\a'
if [ -n "$BASH_VERSION" ]; then
echo -e '\a'
else
echo '\a'
fi
packet_log 20 packet_log 20
if [ "$pause" = "Yes" ]; then if [ "$pause" = "Yes" ]; then
echo -en '\nEnter any character to continue: ' echo
echo -n 'Enter any character to continue: '
read foo read foo
else else
timed_read timed_read
@ -335,26 +354,37 @@ monitor_firewall() # $1 = timeout -- if negative, prompt each time that
fi fi
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo -e "NAT Status\\n" echo
echo "NAT Status"
echo
iptables -t nat -L -n -v iptables -t nat -L -n -v
timed_read timed_read
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo -e "\\nTOS/MARK Status\\n" echo
echo
echo "TOS/MARK Status"
echo
iptables -t mangle -L -n -v iptables -t mangle -L -n -v
timed_read timed_read
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo -e "\\nTracked Connections\\n" echo
echo
echo "Tracked Connections"
echo
cat /proc/net/ip_conntrack cat /proc/net/ip_conntrack
timed_read timed_read
clear clear
echo -e "$banner `date`\\n" echo "$banner `date`"
echo -e "\\nTraffic Shaping/Control\\n" echo
echo
echo "Traffic Shaping/Control"
echo
show_tc show_tc
timed_read timed_read
done done
@ -383,9 +413,11 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
while true; do while true; do
clear 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 show_reset
@ -393,11 +425,18 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
if [ "$rejects" != "$oldrejects" ]; then if [ "$rejects" != "$oldrejects" ]; then
oldrejects="$rejects" oldrejects="$rejects"
echo -e '\a'
if [ -n "$BASH_VERSION" ]; then
echo -e '\a'
else
echo '\a'
fi
packet_log 40 packet_log 40
if [ "$pause" = "Yes" ]; then if [ "$pause" = "Yes" ]; then
echo -en '\nEnter any character to continue: ' echo
echo -n 'Enter any character to continue: '
read foo read foo
else else
timed_read timed_read
@ -445,7 +484,8 @@ usage() # $1 = exit status
# #
show_reset() { show_reset() {
[ -f $STATEDIR/restarted ] && \ [ -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 [ $# -gt 2 ] && usage 1
case "$2" in case "$2" in
connections) connections)
echo -e "Shorewall-$version Connections at $HOSTNAME - `date`\\n" echo "Shorewall-$version Connections at $HOSTNAME - `date`"
echo
cat /proc/net/ip_conntrack cat /proc/net/ip_conntrack
;; ;;
nat) nat)
echo -e "Shorewall-$version NAT at $HOSTNAME - `date`\\n" echo "Shorewall-$version NAT at $HOSTNAME - `date`"
echo
show_reset show_reset
iptables -t nat -L -n -v iptables -t nat -L -n -v
;; ;;
tos|mangle) tos|mangle)
echo -e "Shorewall-$version TOS at $HOSTNAME - `date`\\n" echo "Shorewall-$version TOS at $HOSTNAME - `date`"
echo
show_reset show_reset
iptables -t mangle -L -n -v iptables -t mangle -L -n -v
;; ;;
log) log)
get_config get_config
echo -e "Shorewall-$version Log at $HOSTNAME - `date`\\n" echo "Shorewall-$version Log at $HOSTNAME - `date`"
echo
show_reset show_reset
host=`echo $HOSTNAME | sed 's/\..*$//'` host=`echo $HOSTNAME | sed 's/\..*$//'`
packet_log 20 packet_log 20
;; ;;
tc) tc)
echo -e "Shorewall-$version Traffic Control at $HOSTNAME - `date`\\n" echo "Shorewall-$version Traffic Control at $HOSTNAME - `date`"
echo
show_tc show_tc
;; ;;
*) *)
echo -e "Shorewall-$version Chain $2 at $HOSTNAME - `date`\\n" echo "Shorewall-$version Chain $2 at $HOSTNAME - `date`"
echo
show_reset show_reset
iptables -L $2 -n -v iptables -L $2 -n -v
;; ;;
@ -594,7 +640,8 @@ case "$1" in
[ $# -eq 1 ] || usage 1 [ $# -eq 1 ] || usage 1
get_config get_config
clear clear
echo -e "Shorewall-$version Status at $HOSTNAME - `date`\\n" echo "Shorewall-$version Status at $HOSTNAME - `date`"
echo
show_reset show_reset
host=`echo $HOSTNAME | sed 's/\..*$//'` host=`echo $HOSTNAME | sed 's/\..*$//'`
iptables -L -n -v iptables -L -n -v
@ -611,7 +658,9 @@ case "$1" in
[ $# -eq 1 ] || usage 1 [ $# -eq 1 ] || usage 1
get_config get_config
clear clear
echo -e "Shorewall-$version Hits at $HOSTNAME - `date`\\n" echo "Shorewall-$version Hits at $HOSTNAME - `date`"
echo
timeout=30 timeout=30
if [ `grep -c "Shorewall:" $LOGFILE ` -gt 0 ] ; then if [ `grep -c "Shorewall:" $LOGFILE ` -gt 0 ] ; then