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

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