From 3898edfddbe628548176554700127539fe32fa73 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 30 Sep 2010 17:18:58 -0700 Subject: [PATCH] Make 'show connections' work on ancient distros --- Shorewall/lib.cli | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Shorewall/lib.cli b/Shorewall/lib.cli index 7ab084066..b1a6f41ca 100644 --- a/Shorewall/lib.cli +++ b/Shorewall/lib.cli @@ -520,19 +520,27 @@ show_command() { g_ipt_options="$g_ipt_options $g_ipt_options1" + [ -n "$g_debugging" ] && set -x case "$1" in connections) [ $# -gt 1 ] && usage 1 - if mywhich conntrack ; then + + if [ -d /proc/sys/net/netfilter/ ]; then + local count + local max + count=$(cat /proc/sys/net/netfilter/nf_conntrack_count) + max=$(cat /proc/sys/net/netfilter/nf_conntrack_max) + echo "$g_product $SHOREWALL_VERSION Connections ($count out of $max) at $g_hostname - $(date)" + else echo "$g_product $SHOREWALL_VERSION Connections at $g_hostname - $(date)" - echo + fi + + echo + + if qt mywhich conntrack ; then conntrack -f ipv4 -L else - local count=$(cat /proc/sys/net/netfilter/nf_conntrack_count) - local max=$(cat /proc/sys/net/netfilter/nf_conntrack_max) - echo "$g_product $SHOREWALL_VERSION Connections ($count out of $max) at $g_hostname - $(date)" - echo [ -f /proc/net/ip_conntrack ] && cat /proc/net/ip_conntrack || grep -v '^ipv6' /proc/net/nf_conntrack fi ;;