home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / ROOTDSKS.144 / COLOR144 / usr / lib / setup / SeTDOS < prev    next >
Encoding:
Text File  |  1995-02-27  |  4.2 KB  |  110 lines

  1. #!/bin/sh
  2. # Add DOS partitions.
  3. rm -f /tmp/SeTDOS
  4. DOSLIST="`fdisk -l | fgrep "DOS" 2> /dev/null`" 
  5. HPFSLIST="`fdisk -l | fgrep "HPFS" 2> /dev/null`" 
  6. if [ ! "$HPFSLIST" = "" ]; then
  7.  DOSLIST="`echo -e "$DOSLIST\n$HPFSLIST"`"
  8. fi
  9. if [ ! "$DOSLIST" = "" ]; then # there are DOS or OS/2 partitions:
  10.  cat << EOF > /tmp/tmpmsg
  11.  
  12. The following DOS FAT or OS/2 HPFS partitions were found:
  13.  
  14. $DOSLIST
  15.  
  16. Would you like to make some of these partitions visible from Linux?
  17. EOF
  18.  dialog --title "DOS AND OS/2 PARTITION SETUP" --yesno "`cat /tmp/tmpmsg`" 22 74
  19.  ADDDOS=$?
  20.  rm -f /tmp/tmpmsg
  21.  if [ "$ADDDOS" = "0" ]; then
  22.   cat /dev/null > /tmp/SeTDOS
  23.   while [ 0 ]; do
  24.    USED_DOS_PARTITIONS="`cat /tmp/SeTDOS | fgrep msdos`"
  25.    USED_HPFS_PARTITIONS="`cat /tmp/SeTDOS | fgrep hpfs`"
  26.    if [ ! "$USED_HPFS_PARTITIONS" = "" ]; then
  27.     USED_DOS_PARTITIONS="`echo -e "$USED_DOS_PARTITIONS\n$USED_HPFS_PARTITIONS"`"
  28.    fi
  29.    rm -f /tmp/tmpmsg
  30.    if [ ! "$USED_DOS_PARTITIONS" = "" ]; then
  31.     echo "These DOS or OS/2 partitions have already been added:" > /tmp/tmpmsg
  32.     echo "$USED_DOS_PARTITIONS" >> /tmp/tmpmsg
  33.    fi
  34.    echo "These DOS or OS/2 partitions are available to mount:" >> /tmp/tmpmsg
  35.    echo "$DOSLIST"  >> /tmp/tmpmsg
  36.    echo "Please enter the partition you want to access from Linux," >> /tmp/tmpmsg
  37.    echo "or type [q] to quit adding new partitions: "  >> /tmp/tmpmsg
  38.    dialog --title "CHOOSE PARTITION" --inputbox "`cat /tmp/tmpmsg`" 22 75 2> /tmp/nextp
  39.    if [ $? = 1 ]; then
  40.     rm -f /tmp/tmpmsg /tmp/nextp /tmp/SeTDOS
  41.     exit
  42.    fi
  43.    NEXT_PARTITION="`cat /tmp/nextp`"
  44.    rm -f /tmp/nextp /tmp/tmpmsg
  45.    if [ "$NEXT_PARTITION" = "q" ]; then
  46.     break;
  47.    fi
  48.    if [ ! -b $NEXT_PARTITION ]; then
  49.     dialog --title "INVALID DEVICE" --msgbox "Invalid device. Try again. Use a format such as: \
  50. /dev/hda3 or whatever the device name is." 7 50 
  51.     continue;
  52.    else
  53.     if echo "$DOSLIST" | fgrep $NEXT_PARTITION 1> /dev/null 2> /dev/null ; then
  54.      # Here we should test to be sure the partition has not been used
  55.      if fgrep $NEXT_PARTITION /tmp/SeTDOS 1> /dev/null 2> /dev/null ; then
  56.       # We have already added this partition.
  57.       cat << EOF > /tmp/tmpmsg
  58. Sorry, you have already added the partition $NEXT_DEVICE to the
  59. list of devices that are mounted at boot time. Either choose a
  60. partition you have not yet used, or [q]uit to go on.
  61. EOF
  62.       dialog --title "ERROR: $NEXT_DEVICE ALREADY USED" --msgbox "`cat /tmp/tmpmsg`" 8 70
  63.       rm -f /tmp/tmpmsg
  64.       continue;
  65.      fi
  66.      cat << EOF > /tmp/tmpmsg
  67. Now this new partition must be mounted somewhere in your
  68. directory tree. Please enter the directory under which 
  69. you would like to put it. for instance, you might want to
  70. reply /dosc, /dosd, or something like that. NOTE: This
  71. partition won't actually be mounted until you reboot.
  72.  
  73. Where would you like to mount $NEXT_PARTITION?
  74. EOF
  75.      dialog --title "SELECT MOUNT POINT" --inputbox "`cat /tmp/tmpmsg`" 14 65 2> /tmp/newdir
  76.      if [ $? = 1 ]; then
  77.       rm -f /tmp/tmpmsg /tmp/newdir /tmp/SeTDOS
  78.       exit
  79.      fi
  80.      NEW_DIR="`cat /tmp/newdir`"
  81.      rm -f /tmp/newdir
  82.      if [ ! "`echo $NEW_DIR | cut -b1`" = "/" ]; then
  83.       NEW_DIR="/$NEW_DIR"
  84.      fi
  85.      mkdir -p /mnt$NEW_DIR
  86.      chmod 755 /mnt$NEW_DIR
  87.      echo > /tmp/tmpmsg
  88.      if fdisk -l | fgrep "DOS" | fgrep $NEXT_PARTITION 1> /dev/null 2> /dev/null ; then
  89.       echo "DOS partition added to /etc/fstab:" >> /tmp/tmpmsg
  90.       echo >> /tmp/tmpmsg
  91.       echo "$NEXT_PARTITION        $NEW_DIR        msdos        defaults   1   1" >> /tmp/tmpmsg
  92.       echo "$NEXT_PARTITION        $NEW_DIR        msdos        defaults   1   1" >> /tmp/SeTDOS
  93.      else
  94.       echo "HPFS partition (read only) added to /etc/fstab..." >> /tmp/tmpmsg
  95.       echo >> /tmp/tmpmsg
  96.       echo "$NEXT_PARTITION        $NEW_DIR        hpfs         ro   1   1" >> /tmp/tmpmsg
  97.       echo "$NEXT_PARTITION        $NEW_DIR        hpfs         ro   1   1" >> /tmp/SeTDOS
  98.      fi
  99.      dialog --title "CURRENT DOS/HPFS PARTITION STATUS" \
  100. --msgbox "`cat /tmp/tmpmsg`" 9 75
  101.     else # device not tagged as DOS
  102.      dialog --title "INCORRECT FILESYSTEM TYPE" --msgbox "The partition you have selected is not tagged \
  103. as a DOS or OS/2 partition, please try again." 7 45
  104.      continue;
  105.     fi
  106.    fi
  107.   done # mounting DOS/HPFS partitions
  108.  fi
  109. fi
  110.