cosmetic : displays the node configuration file
[bootcd.git] / conf_files / pl_netinit
index 853543c..b6c6057 100644 (file)
@@ -94,9 +94,8 @@ find_node_config()
 
         # 1. check for new named file first on the floppy disk
        if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
-           echo "pl_netinit: found node configuration file plnode.txt, using"
-
            conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
+           echo "pl_netinit: found node configuration file $conf_file"
            /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
            /bin/umount $CONF_DEVICE_MOUNT_POINT
            return 1
@@ -125,11 +124,11 @@ find_node_config()
 
     echo "pl_netinit: looking for node configuration file on flash based devices"
 
-    # make the sd* expansion fail to an empty string if there are no sd
+    # make the sd* hd* expansion fail to an empty string if there are no sd
     # devices
     shopt -s nullglob
 
-    for device in /sys/block/sd*; do
+    for device in /sys/block/[hs]d*; do
        removable=`cat $device/removable`
        if [[ $removable -ne 1 ]]; then
            continue
@@ -144,9 +143,8 @@ find_node_config()
                $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
            if [[ $? -eq 0 ]]; then
                if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
-                   echo "pl_netinit: found node configuration file plnode.txt, using"
-
                    conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
+                   echo "pl_netinit: found node configuration file $conf_file"
                    /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
                    echo "pl_netinit: found configuration"
                    /bin/umount $CONF_DEVICE_MOUNT_POINT
@@ -166,9 +164,8 @@ find_node_config()
     # 3. see if there is an old file on the floppy disk. if there was,
     # the file $TMP_OLD_FLOPPY_CONF_FILE will be readable.
     if [ -r "$TMP_OLD_FLOPPY_CONF_FILE" ]; then
-       echo "pl_netinit: found node configuration file planet.cnf, using"
-
        conf_file=$TMP_OLD_FLOPPY_CONF_FILE
+       echo "pl_netinit: found node configuration file $conf_file"
        /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
        return 1
     fi
@@ -178,7 +175,7 @@ find_node_config()
     echo "pl_netinit: looking for network configuration on cd in /usr/boot"
     if [ -r "$CD_NET_CONF_BOOT" ]; then
        
-       echo "pl_netinit: found cd configuration file, using"
+       echo "pl_netinit: found cd configuration file $CD_NET_BOOT_CONF"
        /etc/init.d/pl_validateconf < $CD_NET_CONF_BOOT > $USED_NET_CONF
        return 1
     fi
@@ -188,7 +185,7 @@ find_node_config()
     echo "pl_netinit: looking for network configuration on cd in /usr"
     if [ -r "$CD_NET_CONF_ROOT" ]; then
        
-       echo "pl_netinit: found cd configuration file, using"
+       echo "pl_netinit: found cd configuration file $CD_NET_CONF_ROOT"
        /etc/init.d/pl_validateconf < $CD_NET_CONF_ROOT > $USED_NET_CONF
        return 1
     fi
@@ -200,7 +197,7 @@ find_node_config()
     # can inform the users appropriately.
     echo "pl_netinit: using default network configuration"
     if [ -r "$FALLBACK_NET_CONF" ]; then
-       echo "pl_netinit: found cd default configuration file, using"
+       echo "pl_netinit: found cd default configuration file $FALLBACK_NET_CONF"
        /etc/init.d/pl_validateconf < $FALLBACK_NET_CONF > $USED_NET_CONF
        DEFAULT_NET_CONF=1
        return 1
@@ -261,7 +258,7 @@ if [[ -n "$NET_DEVICE" ]]; then
        dev_address=`cat $device/address | tr A-Z a-z`
        if [ "$device" == "$NET_DEVICE" -o "$dev_address" == "$NET_DEVICE" ]; then
            ETH_DEVICE=$device
-           echo "pl_netinit: found device $ETH_DEVICE with mac address $NET_DEVICE"
+           echo "pl_netinit: found device $ETH_DEVICE with mac address $dev_address"
            break
        fi
     done
@@ -300,37 +297,27 @@ if [[ $? -ne 0 ]]; then
     net_init_failed
 fi
 
-if [[ "$IP_METHOD" == "dhcp" ]]; then
-    echo "pl_netinit: attempting to bring up device with dhcp"
-
-    # setup a dhclient conf file for this device (used to send
-    # our hostname to the dhcp server)
-    echo "interface \"$ETH_DEVICE\" {" > $DHCLIENT_CONF_FILE
-    echo "send host-name \"$HOST_NAME.$DOMAIN_NAME\";" >> $DHCLIENT_CONF_FILE
-    echo "}" >> $DHCLIENT_CONF_FILE
-
-    # touch the redhat net device configuration file so 
-    # dhclient doesn't complain
-    /bin/touch /etc/sysconfig/network-scripts/ifcfg-$ETH_DEVICE
-
-    configured=0
-    while [[ $configured -eq 0 ]]; do
-       /sbin/dhclient -1 -cf $DHCLIENT_CONF_FILE $ETH_DEVICE 
-       if [[ $? -ne 0 ]]; then
-           echo "pl_netinit: dhcp failed, retrying in 2 minutes"
-           /bin/sleep 120
-       else
-           echo "pl_netinit: dhcp succeeded"
-           configured=1
-           break
-       fi
-    done
-else
-    echo "pl_netinit: configuring device statically"
+ifcfg=/etc/sysconfig/network-scripts/ifcfg-$ETH_DEVICE
+echo "DEVICE=$ETH_DEVICE" > $ifcfg
+[ -n "$NET_DEVICE" ] && \
+  echo "HWADDR=$NET_DEVICE" >> $ifcfg
+echo "BOOTPROTO=$IP_METHOD" >> $ifcfg
+echo "DHCP_HOSTNAME=$HOST_NAME.$DOMAIN_NAME" >> $ifcfg
+
+if [ -n "$WLAN_SSID$WLAN_IWCONFIG$WLAN_MODE" ]; then
+    [ -n "$WLAN_SSID" ] && \
+      echo "ESSID=$WLAN_SSID" >> $ifcfg
+    [ -n "$WLAN_IWCONFIG" ] && \
+      echo "IWCONFIG=$WLAN_IWCONFIG" >> $ifcfg
+    [ -n "$WLAN_MODE" ] && \
+      echo "MODE=$WLAN_MODE" >> $ifcfg
+fi
+
+if [ "$IP_METHOD" = "static" ]; then
+    echo "IPADDR=$IP_ADDRESS" >> $ifcfg
+    echo "NETMASK=$IP_NETMASK" >> $ifcfg
+    echo "GATEWAY=$IP_GATEWAY" >> $ifcfg
 
-    /sbin/ifconfig $ETH_DEVICE $IP_ADDRESS broadcast $IP_BROADCASTADDR \
-       netmask $IP_NETMASK
-    /sbin/route add default gw $IP_GATEWAY dev $ETH_DEVICE
     /bin/hostname "$HOST_NAME.$DOMAIN_NAME"
 
     if [[ -z "$IP_DNS1" ]]; then
@@ -344,6 +331,10 @@ else
     fi
 fi
 
+
+echo "pl_netinit: attempting to bring up device $ETH_DEVICE"
+/sbin/ifup $ETH_DEVICE
+
 # for backwards compatibility
 /sbin/ifconfig $ETH_DEVICE > $IFCONFIG_OUTPUT