More fixes for compiled programs

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@3314 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2006-01-18 15:07:08 +00:00
parent 21cfe437d0
commit 630bc7bd5d
2 changed files with 44 additions and 33 deletions

View File

@ -1122,9 +1122,9 @@ ${INDENT}addr=\$(ip -f inet addr show $interface 2> /dev/null | grep inet | head
${INDENT}if [ -n "\$addr" ]; then ${INDENT}if [ -n "\$addr" ]; then
${INDENT} addr=\$(echo \$addr | sed 's/inet //;s/\/.*//;s/ peer.*//') ${INDENT} addr=\$(echo \$addr | sed 's/inet //;s/\/.*//;s/ peer.*//')
${INDENT} for network in 10.0.0.0/8 176.16.0.0/12 192.168.0.0/16; do ${INDENT} for network in 10.0.0.0/8 176.16.0.0/12 192.168.0.0/16; do
${INDENT} if in_network \$addr \$network; then ${INDENT} if in_network \$addr \$network; then
${INDENT} fatal_error "The 'norfc1918' option has been specified on an interface with an RFC 1918 address. Interface:$interface" ${INDENT} fatal_error "The 'norfc1918' option has been specified on an interface with an RFC 1918 address. Interface:$interface"
${INDENT} fi ${INDENT} fi
${INDENT} done ${INDENT} done
${INDENT}fi ${INDENT}fi
@ -9379,6 +9379,18 @@ run_tc() {
} }
initialize() { initialize() {
__EOF__
if [ -z "$EXPORT" ]; then
cat >> $RESTOREBASE << __EOF__
if [ ! -f /usr/share/shorewall/version ] || [ \$(cat /usr/share/shorewall/version) != $VERSION ]; then
error_message "ERROR: This script requires Shorewall version $VERSION"
exit 2
fi
__EOF__
fi
cat >> $RESTOREBASE << __EOF__
# #
# These variables are required by the library functions called in this script # These variables are required by the library functions called in this script
# #
@ -9392,33 +9404,22 @@ initialize() {
LOGFORMAT="$LOGFORMAT" LOGFORMAT="$LOGFORMAT"
RESTOREFILE="$RESTOREFILE" RESTOREFILE="$RESTOREFILE"
VERSION="$VERSION" VERSION="$VERSION"
IPTABLES="$IPTABLES"
STOPPING= STOPPING=
# #
# The library requires that /var/lib/shorewall exist # The library requires that /var/lib/shorewall exist
# #
mkdir -p /var/lib/shorewall [ -d /var/lib/shorewall ] || mkdir -p /var/lib/shorewall
} }
__EOF__ __EOF__
if [ -n "$PROGRAM" ]; then save_command "define_firewall() {"
save_command "define_firewall() {" INDENT=" "
INDENT=" "
fi
if [ -z "$EXPORT" ]; then
cat >> $RESTOREBASE << __EOF__
${INDENT}if [ ! -f /usr/share/shorewall/version ] || [ \$(cat /usr/share/shorewall/version) != $VERSION ]; then
${INDENT} error_message "ERROR: This script requires Shorewall version $VERSION"
${INDENT} exit 2
${INDENT}fi
__EOF__
fi
cat >> $RESTOREBASE << __EOF__ cat >> $RESTOREBASE << __EOF__
${INDENT}load_kernel_modules load_kernel_modules
__EOF__ __EOF__
@ -9427,7 +9428,7 @@ __EOF__
initialize_netfilter initialize_netfilter
progress_message2 "Compiling Proxy ARP"; setup_proxy_arp progress_message2 "Compiling Proxy ARP"; setup_proxy_arp
# #
# [re]-Establish routing # [re]-Establish routing
# #
@ -9519,13 +9520,16 @@ __EOF__
run_user_exit started run_user_exit started
INDENT=
save_command "}"
save_command ""
if [ -n "$PROGRAM" ]; then if [ -n "$PROGRAM" ]; then
INDENT=
save_command "}"
save_command ""
cat $(find_file prog.header) $RESTOREBASE $(find_file prog.footer) > $outfile cat $(find_file prog.header) $RESTOREBASE $(find_file prog.footer) > $outfile
rm $RESTOREBASE rm $RESTOREBASE
else else
save_command "initialize"
save_command "define_firewall"
mv -f $RESTOREBASE $outfile mv -f $RESTOREBASE $outfile
fi fi

View File

@ -2,8 +2,8 @@
# Give Usage Information # # Give Usage Information #
################################################################################ ################################################################################
usage() { usage() {
echo "Usage: $0 start|stop|clear|reload|restart|status|version" echo "Usage: $0 [ -q ] [ -n ] [ start|stop|clear|reload|restart|status|version ]"
exit 1 exit $1
} }
################################################################################ ################################################################################
# E X E C U T I O N B E G I N S H E R E # # E X E C U T I O N B E G I N S H E R E #
@ -12,8 +12,7 @@ initialize
finished=0 finished=0
while [ $finished -eq 0 ]; do while [ $finished -eq 0 -a $# -gt 0 ]; do
[ $# -eq 0 ] && usage 1
option=$1 option=$1
case $option in case $option in
-*) -*)
@ -45,11 +44,17 @@ while [ $finished -eq 0 ]; do
done done
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
usage 1 if shorewall_is_started; then
COMMAND=restart
else
COMMAND=start
fi
elif [ $# -gt 1 ]; then
usage 2
else
COMMAND="$1"
fi fi
COMMAND="$1"
case "$COMMAND" in case "$COMMAND" in
start) start)
echo "Starting Shorewall...." echo "Starting Shorewall...."
@ -84,7 +89,7 @@ case "$COMMAND" in
status) status)
echo "Shorewall-$VERSION Status at $HOSTNAME - $(date)" echo "Shorewall-$VERSION Status at $HOSTNAME - $(date)"
echo echo
if iptables -L shorewall -n > /dev/null 2>&1; then if shorewall_is_started; then
echo "Shorewall is running" echo "Shorewall is running"
status=0 status=0
else else
@ -109,9 +114,11 @@ case "$COMMAND" in
echo $VERSION echo $VERSION
status=0 status=0
;; ;;
help)
usage 0
;;
*) *)
usage usage 2
status=2
;; ;;
esac esac