- when checking removable flash devices, check all partitions on it
Mark Huang [Tue, 21 Jun 2005 18:50:18 +0000 (18:50 +0000)]
  (including the case when there are no partitions on it (e.g. just
  /dev/sda instead of /dev/sda1), i.e. the way I'm about to recommend
  that the flash devices be formatted in the documentation: dd
  if=PlanetLab-BootCD-3.0.usb of=/dev/sda)

conf_files/pl_netinit

index a627bd2..1aced1b 100644 (file)
@@ -135,26 +135,29 @@ find_node_config()
            continue
        fi
 
-       check_dev=/dev/`basename $device`1
-
-       echo "pl_netinit: looking for node configuration file on device $check_dev"
-       /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES $check_dev \
-           $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"
-               /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
-               echo "pl_netinit: found configuration"
+       partitions=$(/bin/awk "\$4 ~ /`basename $device`[0-9]*/ { print \$4 }" /proc/partitions)
+       for partition in $partitions ; do
+           check_dev=/dev/$partition
+
+           echo "pl_netinit: looking for node configuration file on device $check_dev"
+           /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES $check_dev \
+               $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"
+                   /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
+                   echo "pl_netinit: found configuration"
+                   /bin/umount $CONF_DEVICE_MOUNT_POINT
+                   return 1
+               fi
+               
+               echo "pl_netinit: not found"
+
                /bin/umount $CONF_DEVICE_MOUNT_POINT
-               return 1
            fi
-           
-           echo "pl_netinit: not found"
-
-           /bin/umount $CONF_DEVICE_MOUNT_POINT
-       fi
+       done
     done
 
     # normal filename expansion setting