mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-27 00:29:02 +01:00
630bc7bd5d
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@3314 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
126 lines
2.1 KiB
Plaintext
126 lines
2.1 KiB
Plaintext
################################################################################
|
|
# Give Usage Information #
|
|
################################################################################
|
|
usage() {
|
|
echo "Usage: $0 [ -q ] [ -n ] [ start|stop|clear|reload|restart|status|version ]"
|
|
exit $1
|
|
}
|
|
################################################################################
|
|
# E X E C U T I O N B E G I N S H E R E #
|
|
################################################################################
|
|
initialize
|
|
|
|
finished=0
|
|
|
|
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
|
option=$1
|
|
case $option in
|
|
-*)
|
|
option=${option#-}
|
|
|
|
[ -z "$option" ] && usage 1
|
|
|
|
while [ -n "$option" ]; do
|
|
case $option in
|
|
q*)
|
|
QUIET=$(($QUIET + 1 ))
|
|
option=${option#q}
|
|
;;
|
|
n*)
|
|
NOROUTES=Yes
|
|
option=${option#n}
|
|
;;
|
|
*)
|
|
usage 1
|
|
;;
|
|
esac
|
|
done
|
|
shift
|
|
;;
|
|
*)
|
|
finished=1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ $# -eq 0 ]; then
|
|
if shorewall_is_started; then
|
|
COMMAND=restart
|
|
else
|
|
COMMAND=start
|
|
fi
|
|
elif [ $# -gt 1 ]; then
|
|
usage 2
|
|
else
|
|
COMMAND="$1"
|
|
fi
|
|
|
|
case "$COMMAND" in
|
|
start)
|
|
echo "Starting Shorewall...."
|
|
define_firewall
|
|
status=$?
|
|
echo "done."
|
|
;;
|
|
stop)
|
|
echo "Stopping Shorewall...."
|
|
stop_firewall
|
|
status=0
|
|
echo "done."
|
|
;;
|
|
restart)
|
|
echo "Restarting Shorewall...."
|
|
define_firewall
|
|
status=$?
|
|
echo "done."
|
|
;;
|
|
reload)
|
|
echo "Reloading Shorewall...."
|
|
define_firewall
|
|
status=$?
|
|
echo "done."
|
|
;;
|
|
clear)
|
|
echo "Clearing Shorewall...."
|
|
clear_firewall
|
|
status=0
|
|
echo "done."
|
|
;;
|
|
status)
|
|
echo "Shorewall-$VERSION Status at $HOSTNAME - $(date)"
|
|
echo
|
|
if shorewall_is_started; then
|
|
echo "Shorewall is running"
|
|
status=0
|
|
else
|
|
echo "Shorewall is stopped"
|
|
status=4
|
|
fi
|
|
|
|
if [ -f /var/lib/shorewall/state ]; then
|
|
state="$(cat /var/lib/shorewall/state)"
|
|
case $state in
|
|
Stopped*|Clear*)
|
|
status=3
|
|
;;
|
|
esac
|
|
else
|
|
state=Unknown
|
|
fi
|
|
echo "State:$state"
|
|
echo
|
|
;;
|
|
version)
|
|
echo $VERSION
|
|
status=0
|
|
;;
|
|
help)
|
|
usage 0
|
|
;;
|
|
*)
|
|
usage 2
|
|
;;
|
|
esac
|
|
|
|
exit $status
|