Author: sparky
Date: Fri Mar  3 01:21:31 2006
New Revision: 7070

Modified:
   ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/net-detect
Log:
- configure correctly if udev has already loaded modules


Modified: ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/net-detect
==============================================================================
--- ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/net-detect     (original)
+++ ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/net-detect     Fri Mar  3 01:21:31 2006
@@ -12,11 +12,42 @@
 
 verbose 1 -G "Setting network cards"
 
+set_ifcfg() {
+       DEV=$1
+       IF=/etc/sysconfig/interfaces/ifcfg-$DEV
+       IP=$2
+       ONBOOT=$3
+       [[ -z $IP ]] && return
+       [[ -e $IF ]] && mv -f ${IF}{,.backup}
+       [[ -n $ONBOOT ]] && ONBOOT=yes
+       verbose 4 "     +-Creating ifcfg-$IF config file"
+       if [ "$IP" == "dhcp" -o "$IP" == "pump" ]; then
+               IPADDR="192.168.1.1/24"
+               BOOTPROTO=$IP
+       else
+               IPADDR=$IP
+               BOOTPROTO=none
+       fi
+
+cat > $IF << EOF
+DEVICE=$DEV
+
+ONBOOT=$ONBOOT
+
+IPADDR=$IPADDR
+BOOTPROTO=$BOOTPROTO
+
+WLAN_NICKNAME="ppcrcd"
+DHCP_OPTIONS="-DHt 15"
+EOF
+}
+
 confnet() {
-       for CONF in /etc/sysconfig/interfaces/ifcfg-eth[0-9]{,[0-9]}; do
-               mv -f $CONF $CONF.backup
-       done
-       
+       ONBOOT=yes
+       if [[ $1 == noboot ]]; then
+               ONBOOT=no
+               shift
+       fi
        COUNT=0
        while [ -n "$1" ]; do
                eth=$1
@@ -27,17 +58,7 @@
                DNS=$( echo $eth | awk -F: '{print $4}')
                verbose 3 "   +-Setting $CARD with $IPB IP"
                echo "alias eth${COUNT} ${CARD}" >> /etc/modprobe.conf
-               ( echo "DEVICE=eth${COUNT}";
-                 if [ "$IPB" == "dhcp" -o "$IPB" == "pump" ]; then
-                       echo "#IPADDR=192.168.1.101/24";
-                       echo "BOOTPROTO=$IPB";
-                 else
-                       echo "IPADDR=$IPB";
-                       echo "BOOTPROTO=none";
-                 fi
-                 echo "ONBOOT=yes";
-                 echo 'DHCP_OPTIONS="-DHt 15"' ) \
-                        > /etc/sysconfig/interfaces/ifcfg-eth${COUNT}
+               set_ifcfg eth${COUNT} $IPB $ONBOOT
                
                if [ -n "$GATE" ]; then
                        sed -i -e "s/^GATEWAY=.*$/GATEWAY=$GATE/" \
@@ -69,7 +90,15 @@
        
        if ! egrep -q "^[[:space:]]*alias[[:space:]]*eth0" /etc/modprobe.conf; 
then
                verbose 2 -B " +-Autodetecting network"
-               confnet $(/usr/bin/pcidev /m net | sed 's/$/:dhcp/')
+               if [[ -d /sys/class/net/eth* ]]; then
+                       # if udev has detected something only setup ifcfg files
+                       for NET in /sys/class/net/eth*; do
+                               set_ifcfg ${NET##*/} dhcp no
+                       done
+               else
+                       #old behaviour
+                       confnet noboot $(/usr/bin/pcidev /m net | sed 
's/$/:dhcp/')
+               fi
        fi
 fi
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to