Viitor_upstart/etc/init/routing.conf
kueller 79b2635d46 Neue Version V963
git-svn-id: svn://svn.compuextreme.de/Viitor/V963/Viitor_upstart@5933 504e572c-2e33-0410-9681-be2bf7408885
2011-01-03 10:48:06 +00:00

42 lines
1.4 KiB
Plaintext

description "Setup Routing depending on several config files"
author "Harald Kueller <harald.kueller@compuextreme.de>"
version 1.0
emits none special
start on stopped ifup
console output
script
source /etc/init/functions
if [ ! -f /etc/sysconfig/net/notrouter ]; then
echo "Configuring System with routing allowed"
if [ -f /etc/sysconfig/net/gateways ]; then
sed -e "/^#/d" /etc/sysconfig/net/gateways | \
sed -e "/^ *$/d" >/tmp/gateways
exec 3</tmp/gateways
while read <&3 TYPE NETWORK OPTION GW NETMASK; do
if [ "$OPTION" == "dev" ]; then
/sbin/route add -$TYPE $NETWORK netmask $NETMASK dev $GW
status_message "Device route to $NETWORK with $NETMASK on $GW"
fi
if [ "$OPTION" == "gw" ]; then
/sbin/route add -$TYPE $NETWORK netmask $NETMASK gw $GW
status_message "Net Route to $NETWORK with $NETMASK and gw $GW"
fi
done
exec 3>&-
rm /tmp/gateways
fi
if [ -f /etc/sysconfig/net/defaultrouter ]; then
/sbin/route add default gw `cat /etc/sysconfig/net/defaultrouter`
status_message "Default Router set to `cat /etc/sysconfig/net/defaultrouter`"
fi
NUMIF=`/sbin/ip -f inet addr show|/bin/grep inet|/bin/grep -v "host lo"|wc -l`
if [ $NUMIF -gt 2 ]; then
echo "1" >/proc/sys/net/ipv4/ip_forward
status_message "Enable of ip_forwarding"
fi
fi
end script