Extend 'version -a' behavior to all CLIs

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2010-05-31 07:32:17 -07:00
parent 47c4cbd85a
commit 858a422da3
4 changed files with 111 additions and 17 deletions

View File

@ -390,6 +390,55 @@ usage() # $1 = exit status
exit $1
}
version_command() {
local finished
finished=0
local all
all=
local product
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=
;;
a*)
all=Yes
option=${option#a}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
[ $# -gt 0 ] && usage 1
echo $SHOREWALL_VERSION
if [ -n "$all" ]; then
for product in shorewall shorewall6 shorewall6-lite shorewall-init; do
if [ -f /usr/share/$product/version ]; then
echo "$product: $(cat /usr/share/$product/version)"
fi
done
fi
}
#
# Execution begins here
#
@ -633,7 +682,8 @@ case "$COMMAND" in
hits_command $@
;;
version)
echo $SHOREWALL_VERSION Lite
shift
version_command $@
;;
logwatch)
logwatch_command $@

View File

@ -1541,23 +1541,15 @@ version_command() {
[ $# -gt 0 ] && usage 1
echo $SHOREWALL_VERSION
if [ -n "$all" ]; then
for product in shorewall shorewall6 shorewall-lite shorewall6-lite shorewall-init; do
for product in shorewall6 shorewall-lite shorewall6-lite shorewall-init; do
if [ -f /usr/share/$product/version ]; then
case $product in
shorewall)
echo $SHOREWALL_VERSION
;;
*)
echo "$product: $(cat /usr/share/$product/version)"
;;
esac
echo "$product: $(cat /usr/share/$product/version)"
fi
done
else
echo $SHOREWALL_VERSION
fi
}
if [ $# -eq 0 ]; then

View File

@ -373,6 +373,55 @@ usage() # $1 = exit status
exit $1
}
version_command() {
local finished
finished=0
local all
all=
local product
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=
;;
a*)
all=Yes
option=${option#a}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
[ $# -gt 0 ] && usage 1
echo $SHOREWALL_VERSION
if [ -n "$all" ]; then
for product in shorewall shorewall6 shorewall-lite shorewall-init; do
if [ -f /usr/share/$product/version ]; then
echo "$product: $(cat /usr/share/$product/version)"
fi
done
fi
}
#
# Execution begins here
#
@ -613,7 +662,8 @@ case "$COMMAND" in
hits_command $@
;;
version)
echo $SHOREWALL_VERSION Lite
shift
version_command $@
;;
logwatch)
logwatch_command $@

View File

@ -1458,9 +1458,11 @@ version_command() {
echo $SHOREWALL_VERSION
if [ -n "$all" ]; then
if [ -f /usr/share/shorewall/version ]; then
echo "Shorewall $(cat /usr/share/shorewall/version)"
fi
for product in shorewall shorewall-lite shorewall6-lite shorewall-init; do
if [ -f /usr/share/$product/version ]; then
echo "$product: $(cat /usr/share/$product/version)"
fi
done
fi
}