2006-01-25 05:50:05 +01:00
|
|
|
#
|
|
|
|
# Give Usage Information
|
|
|
|
#
|
2006-01-18 00:27:54 +01:00
|
|
|
usage() {
|
2006-02-03 16:10:46 +01:00
|
|
|
echo "Usage: $0 [ -q ] [ -v ] [ -n ] [ start|stop|clear|restart|status|version ]"
|
2006-01-18 16:07:08 +01:00
|
|
|
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 ))
|
2006-01-24 18:44:19 +01:00
|
|
|
option=${option#q}
|
2006-01-23 21:47:30 +01:00
|
|
|
;;
|
2006-01-18 01:29:19 +01:00
|
|
|
n*)
|
|
|
|
NOROUTES=Yes
|
|
|
|
option=${option#n}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
finished=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2006-01-25 23:33:50 +01:00
|
|
|
if [ $# -ne 1 ]; then
|
2006-01-18 16:07:08 +01:00
|
|
|
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)
|
2006-01-24 00:30:58 +01:00
|
|
|
if shorewall_is_started; then
|
|
|
|
error_message "Shorewall is already Running"
|
|
|
|
status=1
|
|
|
|
else
|
|
|
|
progress_message3 "Starting Shorewall...."
|
|
|
|
define_firewall
|
|
|
|
status=$?
|
2006-02-23 16:50:53 +01:00
|
|
|
[ $status = 0 -a -n "$SUBSYSLOCK" ] && touch $SUBSYSLOCK
|
2006-01-24 00:30:58 +01:00
|
|
|
progress_message3 "done."
|
|
|
|
fi
|
2006-01-18 00:27:54 +01:00
|
|
|
;;
|
|
|
|
stop)
|
2006-01-24 00:30:58 +01:00
|
|
|
progress_message3 "Stopping Shorewall...."
|
2006-01-18 00:27:54 +01:00
|
|
|
stop_firewall
|
|
|
|
status=0
|
2006-02-23 16:50:53 +01:00
|
|
|
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
2006-01-24 00:30:58 +01:00
|
|
|
progress_message3 "done."
|
2006-01-18 00:27:54 +01:00
|
|
|
;;
|
|
|
|
restart)
|
2006-01-24 00:30:58 +01:00
|
|
|
if shorewall_is_started; then
|
|
|
|
progress_message3 "Restarting Shorewall...."
|
|
|
|
else
|
|
|
|
echo "Shorewall is not running" >&2
|
|
|
|
progress_message3 "Starting Shorewall...."
|
|
|
|
fi
|
|
|
|
|
2006-01-18 02:42:24 +01:00
|
|
|
define_firewall
|
|
|
|
status=$?
|
2006-01-25 05:18:52 +01:00
|
|
|
progress_message3 "done."
|
|
|
|
;;
|
|
|
|
restore)
|
|
|
|
restore_firewall
|
|
|
|
status=$?
|
2006-02-23 16:50:53 +01:00
|
|
|
[ $status = 0 -a -n "$SUBSYSLOCK" ] && touch $SUBSYSLOCK
|
2006-01-18 02:42:24 +01:00
|
|
|
;;
|
2006-01-18 00:27:54 +01:00
|
|
|
clear)
|
2006-01-24 00:30:58 +01:00
|
|
|
progress_message3 "Clearing Shorewall...."
|
2006-01-18 00:27:54 +01:00
|
|
|
clear_firewall
|
|
|
|
status=0
|
2006-02-23 16:50:53 +01:00
|
|
|
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
2006-01-24 00:30:58 +01:00
|
|
|
progress_message3 "done."
|
2006-01-18 00:27:54 +01:00
|
|
|
;;
|
|
|
|
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
|