X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sbin%2Fgrml-router;h=cd1e19d666d15ab3253ab483543b0c4103f51187;hb=af7e79258099000fb08013a77e1e83680ca4a59f;hp=c7c0e167569c151e099283969d6290926adddef1;hpb=a83e3825511532c96dd400447f2e0cc5e89600dd;p=grml-network.git diff --git a/sbin/grml-router b/sbin/grml-router index c7c0e16..cd1e19d 100755 --- a/sbin/grml-router +++ b/sbin/grml-router @@ -1,45 +1,39 @@ #!/bin/sh # Filename: grml-router # Purpose: set up your box as NAT-router -# Authors: grml-team (grml.org), Ulrich Dangel , Michael Prokop +# Authors: grml-team (grml.org), Ulrich Dangel , Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Sam Okt 07 23:18:38 CEST 2006 [mika] ################################################################################ -# exit on any error -set -e - CONFIG_FILE=/etc/grml/routersetup . /etc/grml/lsb-functions . /etc/grml/net-functions . /etc/grml/script-functions -if [ $UID != 0 ]; then - eerror "Error: become root before starting $0" - exit 100 -fi +check4root || exit 1 -if ! [ -r $CONFIG_FILE ] ; then - eerror "$CONFIG_FILE could not be read." - exit 1 +if [ -r "$CONFIG_FILE" ] ; then + . "$CONFIG_FILE" +else + ewarn "Could not read $CONFIG_FILE" fi -. $CONFIG_FILE - -if [ -z "$OUTDEV" ] ; then - eerror "Outgouing device is not set in $CONFIG_FILE" - exit 1 -fi +# defaults if unconfigured +[ -n "$OUTDEV" ] || OUTDEV=auto +[ -n "$IPTABLES" ] || IPTABLES=/sbin/iptables case "$OUTDEV" in - auto|default) + auto|default) OUTDEV=$(defaultGWDev) + if [ -z "$OUTDEV" ] ; then + eerror "The outgoing device could not be determined." + eerror "Please adjust OUTDEV in $CONFIG_FILE or set OUTDEV as environment variable" + exit 1 + fi ;; esac -[ -n "$IPTABLES" ] || IPTABLES=/sbin/iptables - check4progs $IPTABLES || exit 1 case "$1" in