home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # Add DOS partitions.
- rm -f /tmp/SeTDOS
- ROOTD=`cat /tmp/SeTrootdev`
- DOSLIST="`fdisk -l | fgrep "DOS" | fgrep -v $ROOTD 2> /dev/null`"
- HPFSLIST="`fdisk -l | fgrep "HPFS" 2> /dev/null`"
- if [ ! "$HPFSLIST" = "" ]; then
- DOSLIST="`echo -e "$DOSLIST\n$HPFSLIST"`"
- fi
- if [ ! "$DOSLIST" = "" ]; then # there are DOS or OS/2 partitions:
- cat << EOF > /tmp/tmpmsg
-
- The following DOS FAT or OS/2 HPFS partitions were found:
-
- $DOSLIST
-
- Would you like to make some of these partitions visible from Linux?
- EOF
- dialog --title "DOS AND OS/2 PARTITION SETUP" --yesno "`cat /tmp/tmpmsg`" 22 74
- ADDDOS=$?
- rm -f /tmp/tmpmsg
- if [ "$ADDDOS" = "0" ]; then
- cat /dev/null > /tmp/SeTDOS
- while [ 0 ]; do
- USED_DOS_PARTITIONS="`cat /tmp/SeTDOS | fgrep msdos`"
- USED_HPFS_PARTITIONS="`cat /tmp/SeTDOS | fgrep hpfs`"
- if [ ! "$USED_HPFS_PARTITIONS" = "" ]; then
- USED_DOS_PARTITIONS="`echo -e "$USED_DOS_PARTITIONS\n$USED_HPFS_PARTITIONS"`"
- fi
- rm -f /tmp/tmpmsg
- if [ ! "$USED_DOS_PARTITIONS" = "" ]; then
- echo "These DOS or OS/2 partitions have already been added:" > /tmp/tmpmsg
- echo "$USED_DOS_PARTITIONS" >> /tmp/tmpmsg
- fi
- echo "These DOS or OS/2 partitions are available to mount:" >> /tmp/tmpmsg
- echo "$DOSLIST" >> /tmp/tmpmsg
- echo "Please enter the partition you want to access from Linux," >> /tmp/tmpmsg
- echo "or type [q] to quit adding new partitions: " >> /tmp/tmpmsg
- dialog --title "CHOOSE PARTITION" --inputbox "`cat /tmp/tmpmsg`" 22 75 2> /tmp/nextp
- if [ $? = 1 ]; then
- rm -f /tmp/tmpmsg /tmp/nextp /tmp/SeTDOS
- exit
- fi
- NEXT_PARTITION="`cat /tmp/nextp`"
- rm -f /tmp/nextp /tmp/tmpmsg
- if [ "$NEXT_PARTITION" = "q" ]; then
- break;
- fi
- if [ ! -b $NEXT_PARTITION ]; then
- dialog --title "INVALID DEVICE" --msgbox "Invalid device. Try again. Use a format such as: \
- /dev/hda3 or whatever the device name is." 7 50
- continue;
- else
- if echo "$DOSLIST" | fgrep $NEXT_PARTITION 1> /dev/null 2> /dev/null ; then
- # Here we should test to be sure the partition has not been used
- if fgrep $NEXT_PARTITION /tmp/SeTDOS 1> /dev/null 2> /dev/null ; then
- # We have already added this partition.
- cat << EOF > /tmp/tmpmsg
- Sorry, you have already added the partition $NEXT_DEVICE to the
- list of devices that are mounted at boot time. Either choose a
- partition you have not yet used, or [q]uit to go on.
- EOF
- dialog --title "ERROR: $NEXT_DEVICE ALREADY USED" --msgbox "`cat /tmp/tmpmsg`" 8 70
- rm -f /tmp/tmpmsg
- continue;
- fi
- cat << EOF > /tmp/tmpmsg
- Now this new partition must be mounted somewhere in your directory
- tree. Please enter the directory under which you would like to put
- it. For instance, you might want to reply /dosc, /dosd, or
- something like that. Do not use /DOS - this is reserved by the
- umsdos filesystem.
-
- Where would you like to mount $NEXT_PARTITION?
- EOF
- dialog --title "SELECT MOUNT POINT" --inputbox "`cat /tmp/tmpmsg`" 14 74 2> /tmp/newdir
- if [ $? = 1 ]; then
- rm -f /tmp/tmpmsg /tmp/newdir /tmp/SeTDOS
- exit
- fi
- NEW_DIR="`cat /tmp/newdir`"
- rm -f /tmp/newdir
- if [ ! "`echo $NEW_DIR | cut -b1`" = "/" ]; then
- NEW_DIR="/$NEW_DIR"
- fi
- mkdir -p /mnt/linux$NEW_DIR
- chmod 755 /mnt/linux$NEW_DIR
- echo > /tmp/tmpmsg
- if fdisk -l | fgrep "DOS" | fgrep $NEXT_PARTITION 1> /dev/null 2> /dev/null ; then
- echo "DOS partition added to /etc/fstab:" >> /tmp/tmpmsg
- echo >> /tmp/tmpmsg
- echo "$NEXT_PARTITION $NEW_DIR msdos defaults 1 1" >> /tmp/tmpmsg
- echo "$NEXT_PARTITION $NEW_DIR msdos defaults 1 1" >> /tmp/SeTDOS
- else
- echo "HPFS partition (read only) added to /etc/fstab..." >> /tmp/tmpmsg
- echo >> /tmp/tmpmsg
- echo "$NEXT_PARTITION $NEW_DIR hpfs ro 1 1" >> /tmp/tmpmsg
- echo "$NEXT_PARTITION $NEW_DIR hpfs ro 1 1" >> /tmp/SeTDOS
- fi
- dialog --title "CURRENT DOS/HPFS PARTITION STATUS" \
- --msgbox "`cat /tmp/tmpmsg`" 9 75
- else # device not tagged as DOS
- dialog --title "INCORRECT FILESYSTEM TYPE" --msgbox "The partition you have selected is not tagged \
- as a DOS or OS/2 partition, please try again." 7 45
- continue;
- fi
- fi
- done # mounting DOS/HPFS partitions
- fi
- fi
-