Implement 'status -i'

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2014-06-18 11:07:37 -07:00
parent 4e5d24fd9b
commit ac4bf15606
4 changed files with 81 additions and 6 deletions

View File

@ -2952,9 +2952,74 @@ show_status() {
} }
interface_status() {
case $(cat $1) in
0)
echo Enabled
;;
1)
echo Disabled
;;
*)
echo Unknown
;;
esac
}
show_interfaces() {
local f
local interface
local printed
for f in ${VARDIR}/*.status; do
interface=$(basename $f)
echo " Interface ${interface%.status} is $(interface_status $f)"
printed=Yes
done
[ -n "$printed" ] && echo
}
status_command() { status_command() {
local finished
finished=0
local option
local interfaces
while [ $finished -eq 0 -a $# -gt 0 ]; do
option=$1
case $option in
-*)
option=${option#-}
while [ -n "$option" ]; do
case $option in
-)
finished=1
option=
;;
i*)
interfaces=Yes
option=${option#i}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
[ $# -eq 0 ] || usage 1
[ $VERBOSITY -ge 1 ] && echo "${g_product}-$SHOREWALL_VERSION Status at $g_hostname - $(date)" && echo [ $VERBOSITY -ge 1 ] && echo "${g_product}-$SHOREWALL_VERSION Status at $g_hostname - $(date)" && echo
show_status show_status
[ -n "$interfaces" ] && show_interfaces
exit $status exit $status
} }
@ -3488,7 +3553,7 @@ usage() # $1 = exit status
echo " [ show | list | ls ] zones" echo " [ show | list | ls ] zones"
echo " start [ -f ] [ -p ] [ <directory> ]" echo " start [ -f ] [ -p ] [ <directory> ]"
echo " stop" echo " stop"
echo " status" echo " status [ -i ]"
echo " version [ -a ]" echo " version [ -a ]"
echo echo
exit $1 exit $1
@ -3739,10 +3804,10 @@ shorewall_cli() {
show_command $@ show_command $@
;; ;;
status) status)
[ $# -eq 1 ] || usage 1
[ "$(id -u)" != 0 ] && fatal_error "The status command may only be run by root" [ "$(id -u)" != 0 ] && fatal_error "The status command may only be run by root"
get_config get_config
status_command shift
status_command $@
;; ;;
dump) dump)
get_config Yes No Yes get_config Yes No Yes

View File

@ -1695,7 +1695,7 @@ usage() # $1 = exit status
echo " [ show | list | ls ] vardir" echo " [ show | list | ls ] vardir"
echo " [ show | list | ls ] zones" echo " [ show | list | ls ] zones"
echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ -T ] [ -i ] [ <directory> ]" echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ -T ] [ -i ] [ <directory> ]"
echo " status" echo " status [ -i ]"
echo " stop" echo " stop"
echo " try <directory> [ <timeout> ]" echo " try <directory> [ <timeout> ]"
echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [-t] [-A] [ <directory> ]" echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [-t] [-A] [ <directory> ]"

View File

@ -664,7 +664,8 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>status</option></arg> <arg choice="plain"><arg
choice="plain"><option>status</option><arg><option>-i</option></arg></arg></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@ -1775,6 +1776,10 @@
<listitem> <listitem>
<para>Produces a short report about the state of the <para>Produces a short report about the state of the
Shorewall-configured firewall.</para> Shorewall-configured firewall.</para>
<para>The <option>-i </option>option was added in Shorewall 4.6.2
and causes the status of each optional interface to be
displayed.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -581,7 +581,8 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>status</option></arg> <arg choice="plain"><arg
choice="plain"><option>status</option><arg><option>-i</option></arg></arg></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@ -1611,6 +1612,10 @@
<listitem> <listitem>
<para>Produces a short report about the state of the <para>Produces a short report about the state of the
Shorewall6-configured firewall.</para> Shorewall6-configured firewall.</para>
<para>The <option>-i </option>option was added in Shorewall 4.6.2
and causes the status of each optional interface to be
displayed.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>