2006-01-18 00:27:54 +01:00
|
|
|
################################################################################
|
|
|
|
# Give Usage Information #
|
|
|
|
################################################################################
|
|
|
|
usage() {
|
2006-01-18 16:07:08 +01:00
|
|
|
echo "Usage: $0 [ -q ] [ -n ] [ start|stop|clear|reload|restart|status|version ]"
|
|
|
|
exit $1
|
2006-01-18 00:27:54 +01:00
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
# E X E C U T I O N B E G I N S H E R E #
|
|
|
|
################################################################################
|
|
|
|
initialize
|
|
|
|
|
2006-01-18 01:29:19 +01:00
|
|
|
finished=0
|
|
|
|
|
2006-01-18 16:07:08 +01:00
|
|
|
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
2006-01-18 01:29:19 +01:00
|
|
|
option=$1
|
|
|
|
case $option in
|
|
|
|
-*)
|
|
|
|
option=${option#-}
|
|
|
|
|
|
|
|
[ -z "$option" ] && usage 1
|
|
|
|
|
|
|
|
while [ -n "$option" ]; do
|
|
|
|
case $option in
|
2006-01-23 02:41:24 +01:00
|
|
|
v*)
|
|
|
|
VERBOSE=$(($VERBOSE + 1 ))
|
|
|
|
option=${option#v}
|
2006-01-18 01:29:19 +01:00
|
|
|
;;
|
2006-01-23 21:47:30 +01:00
|
|
|
q*)
|
|
|
|
VERBOSE=$(($VERBOSE - 1 ))
|
|
|
|
option=${option#v}
|
|
|
|
;;
|
2006-01-18 01:29:19 +01:00
|
|
|
n*)
|
|
|
|
NOROUTES=Yes
|
|
|
|
option=${option#n}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
finished=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
2006-01-18 16:07:08 +01:00
|
|
|
if shorewall_is_started; then
|
|
|
|
COMMAND=restart
|
|
|
|
else
|
|
|
|
COMMAND=start
|
|
|
|
fi
|
|
|
|
elif [ $# -gt 1 ]; then
|
|
|
|
usage 2
|
|
|
|
else
|
|
|
|
COMMAND="$1"
|
2006-01-18 01:29:19 +01:00
|
|
|
fi
|
|
|
|
|
2006-01-18 00:27:54 +01:00
|
|
|
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."
|
|
|
|
;;
|
2006-01-18 02:42:24 +01:00
|
|
|
reload)
|
|
|
|
echo "Reloading Shorewall...."
|
|
|
|
define_firewall
|
|
|
|
status=$?
|
|
|
|
echo "done."
|
|
|
|
;;
|
2006-01-18 00:27:54 +01:00
|
|
|
clear)
|
|
|
|
echo "Clearing Shorewall...."
|
|
|
|
clear_firewall
|
|
|
|
status=0
|
|
|
|
echo "done."
|
|
|
|
;;
|
|
|
|
status)
|
2006-01-18 01:29:19 +01:00
|
|
|
echo "Shorewall-$VERSION Status at $HOSTNAME - $(date)"
|
2006-01-18 00:27:54 +01:00
|
|
|
echo
|
2006-01-18 16:07:08 +01:00
|
|
|
if shorewall_is_started; then
|
2006-01-18 00:27:54 +01:00
|
|
|
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
|
|
|
|
;;
|
2006-01-18 01:29:19 +01:00
|
|
|
version)
|
|
|
|
echo $VERSION
|
|
|
|
status=0
|
|
|
|
;;
|
2006-01-18 16:07:08 +01:00
|
|
|
help)
|
|
|
|
usage 0
|
|
|
|
;;
|
2006-01-18 00:27:54 +01:00
|
|
|
*)
|
2006-01-18 16:07:08 +01:00
|
|
|
usage 2
|
2006-01-18 00:27:54 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $status
|