home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- . /etc/init.d/functions
-
- # Check if th /etc/sysconfig/network file exists
- if [ ! -e /etc/sysconfig/network ] ; then
- echo
- echo "/etc/sysconfig/network does not exist. Networking will not be enabled."
- echo
- exit
- fi
-
- . /etc/sysconfig/network
-
- # If the NETWORKING variable in /etc/sysconfig/network
- # is not yes, do not enable networking
- if [ "x$NETWORKING" != "xyes" ] ; then
- echo
- echo "Networking has been disabled in /etc/sysconfig/network"
- echo
- exit
- fi
-
-
- # This script tries to automatically determine the
- # appropriate network configuration.
- # First, it will try to find a DHCP server and get an IP address.
- # If that doesn't work...
-
- ifconfig lo 127.0.0.1
-
- #First, make sure dhcpcd is not already running
- pkill dhcpcd
- route delete default
-
-
- #Now, go through the most likely devices and try to configure them
-
-
-
- ACTIVEIP=0
- IFCFGSCRIPTS=`ls -1 /etc/sysconfig/network-scripts/ifcfg-*`
- for I in $IFCFGSCRIPTS ; do
- /etc/rc.d/init.d/ifup $I
-
- if [ $? -eq 0 ] ; then
- let ACTIVEIP++
- fi
-
-
- done
-
- echo "Active IPs $ACTIVEIP"
- if [ "x$GATEWAY" != "x" -a $ACTIVEIP -ne 0 ] ; then
- echo "Adding default route"
- route add default gw $GATEWAY
- fi
-
-