From b828793da9643621ed0041c059420daad6530ca9 Mon Sep 17 00:00:00 2001 From: teastep Date: Sat, 30 Jul 2005 21:59:12 +0000 Subject: [PATCH] Recombine the 'status' and 'state' commands git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@2434 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/help | 15 ++++----------- Shorewall/releasenotes.txt | 6 ++---- Shorewall/shorewall | 26 ++++++++++---------------- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/Shorewall/help b/Shorewall/help index 0a196a00e..9885d64b8 100755 --- a/Shorewall/help +++ b/Shorewall/help @@ -302,18 +302,11 @@ status) shorewall status - Displays the Shorewall status (running/not-running)." - ;; + Displays the Shorewall status (running/not-running). -state) - echo "state: state - - shorewall state - - Displays the Shorewall state as shown in the state diagram at - http://www.shorewall.net/starting_and_stopping_shorewall. If Shorewall - has been started since installed, the time at which Shorewall was last - started/restarted/refreshed or reset is displayed." + Also displays the Shorewall state as shown in the state diagram at + http://www.shorewall.net/starting_and_stopping_shorewall. The time and + date when that state was reached is also displayed." ;; trace) diff --git a/Shorewall/releasenotes.txt b/Shorewall/releasenotes.txt index e700ed000..935df8216 100755 --- a/Shorewall/releasenotes.txt +++ b/Shorewall/releasenotes.txt @@ -147,16 +147,14 @@ Migration Considerations: 7) The "shorewall status" command now just gives the status of Shorewall (started or not-started). The previous status command has - been renamed "dump". - - A new "state" command gives the Shorewall state relative to the + been renamed "dump". The command also shows the state relative to the state diagram at http://shorewall.net/starting_and_stopping_shorewall.htm. In addition to the state, the time and date at which that state was entered is shown. Note that at least one "shorewall [re]start" must be issued after - upgrading to this release before "shorewall state" will show + upgrading to this release before "shorewall status" will show anything but "Unknown" for the state. New Features in Shorewall 2.5.0 diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 5dbf54028..421d4c0a8 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -42,7 +42,6 @@ # plus the last 20 "interesting" # packets # shorewall status Displays firewall status -# shorewall state Displays firewall state # shorewall reset Resets iptables packet and # byte counts # shorewall clear Open the floodgates by @@ -521,7 +520,6 @@ usage() # $1 = exit status echo " show [ [ ... ]|actions|capabilities|classifiers|connections|log|nat|tc|tos|zones]" echo " start [ ]" echo " stop" - echo " state" echo " status" echo " try [ ]" echo " version" @@ -918,33 +916,29 @@ case "$1" in ;; status) [ $# -eq 1 ] || usage 1 + echo "Shorewall-$version Status at $HOSTNAME - $(date)" + echo if shorewall_is_started ; then echo "Shorewall is running" - exit 0 + status=0 + else + echo "Shorewall is stopped" + status=4 fi - echo "Shorewall is stopped" - status=4 if [ -f /var/lib/shorewall/state ]; then - case $(cat /var/lib/shorewall/state) in + state="$(cat /var/lib/shorewall/state)" + case $state in Stopped*|Clear*) status=3 ;; esac - fi - exit $status - ;; - state) - [ $# -eq 1 ] || usage 1 - echo "Shorewall-$version State at $HOSTNAME - $(date)" - echo - if [ -f /var/lib/shorewall/state ]; then - state=$(cat /var/lib/shorewall/state) else state=Unknown fi - echo "The Shorewall state is $state" + echo "State:$state" echo + exit $status ;; dump) [ -n "$debugging" ] && set -x