home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- T_PX=/mnt
- if [ ! -r /tmp/SeTplist ]; then
- # Give warning?
- exit
- else
- PARTLIST="`cat /tmp/SeTplist`"
- fi
- #ROOT_DEVICE="`cat /tmp/SeTrootdev`"
- while [ 0 ]; do
- if [ ! "`echo "$PARTLIST" | sed -n '2 p'`" = "" ]; then # more than one:
- ONLY_ONE="false"
- else
- ONLY_ONE="true"
- fi
- echo > /tmp/tmpmsg
- echo " Device Boot Begin Start End Blocks Id System" >> /tmp/tmpmsg
- echo "$PARTLIST" >> /tmp/tmpmsg
- if [ "$ONLY_ONE" = "false" ]; then
- echo >> /tmp/tmpmsg
- echo "Which device would you like to use for your root Linux partition?" >> /tmp/tmpmsg
- dialog --title "The following partitions are available for Linux:" \
- --inputbox "`cat /tmp/tmpmsg`" 20 72 2> /tmp/rootdev
- if [ $? = 1 -o $? = 255 ]; then
- rm -f /tmp/tmpmsg
- exit
- fi
- ROOT_DEVICE="`cat /tmp/rootdev`"
- rm -f /tmp/rootdev
- else
- dialog --title "Using this partition for Linux:" \
- --msgbox "`cat /tmp/tmpmsg`" 8 72
- if [ $? = 255 ]; then
- rm -f /tmp/tmpmsg
- exit
- fi
- ROOT_DEVICE="`echo "$PARTLIST" | cut -b1-10`"
- fi
- rm -f /tmp/tmpmsg
- if [ ! -b $ROOT_DEVICE ]; then
- dialog --msgbox "Invalid device. Try again. Use a format such as: \
- /dev/hda3 or whatever the device name is." 7 50
- if [ $? = 255 ]; then
- exit
- fi
- continue;
- fi
- if fdisk -l | fgrep "Linux native" | fgrep $ROOT_DEVICE 1> /dev/null 2> /dev/null ; then
- echo "$ROOT_DEVICE" > /tmp/SeTrootdev
- ROOT_SIZE="`fdisk -l | fgrep "$ROOT_DEVICE" | cut -b38-45 2> /dev/null`"
- # dialog --title "CHOOSE LINUX FILESYSTEM" --menu "\
- #There are two main filesystem types that are used for Linux. These are \
- #the xiafs filesystem, and the second extended filesystem (ext2). \
- #Ext2 seems to be the current standard. Xiafs hasn't really been changed \
- #in quite some time. Ext2 has one really nice feature that xiafs doesn't have: \
- #as an ext2 partition is unmounted, a clean bit is written to it. When the \
- #machine is rebooted, checking is skipped for any partitions that have the \
- #clean bit on them. Xiafs may be a better choice for machines with low memory, \
- #however, so it's still supported. \
- #What filesystem do you plan to use on your root partition \
- #($ROOT_DEVICE), ext2fs or xiafs? " 20 65 2 \
- #"ext2" "Linux Second Extended Filesystem" \
- #"xiafs" "Linux Xiafs" 2> /tmp/filesys
- # if [ $? = 1 -o $? = 255 ]; then
- # exit
- # fi
- # ROOT_SYS_TYPE="`cat /tmp/filesys`"
- # rm -f /tmp/filesys
- ROOT_SYS_TYPE=ext2
- dialog --title "FORMAT PARTITION" --menu "If this partition has not been formatted, you should \
- format it. NOTE: This will erase all data on it. If you are trying to upgrade an \
- existing Linux partition, you should use setup from your hard drive, not from \
- the boot/root disk. (The versions of setup supplied on the hard drive and the \
- boot/root disk differ) Would you like to format this partition?" 15 70 3 \
- "Format" "Quick format with no bad block checking" \
- "Check" "Slow format that checks for bad blocks" \
- "No" "No, do not format this partition" 2> /tmp/format
- if [ $? = 1 -o $? = 255 ]; then
- exit
- fi
- DOFORMAT="`cat /tmp/format`"
- rm -f /tmp/format
- if [ "$DOFORMAT" = "Format" -o "$DOFORMAT" = "Check" ]; then
- if [ "$ROOT_SYS_TYPE" = "ext2" ]; then
- dialog --title "SELECT INODE DENSITY" --menu "Ext2fs defaults to one \
- inode per 4096 bytes of drive space. If you're going to have many small files \
- on your drive, then you may need more inodes (one is used for each file \
- entry). You can change the density to one inode per 2048 bytes, or even per \
- 1024 bytes. Select '2048' or '1024', or just hit enter to accept the default \
- of 4096 bytes. NOTE: If you are going to run from CD using a small (<60MB) \
- partition, use 1024 to be safe. Each link uses an inode and it's easy to \
- run out of space." 18 65 3 \
- "4096" "1 inode per 4096 bytes. (default)" \
- "2048" "1 inode per 2048 bytes." \
- "1024" "1 inode per 1024 bytes." 2> /tmp/density
- DENSITY="`cat /tmp/density`"
- rm -f /tmp/density
- if [ ! "$DENSITY" = "2048" -a ! "$DENSITY" = "1024" ]; then
- DENSITY=4096
- fi
- INODE_DENSITY="Inode density: 1 inode per $DENSITY bytes."
- fi
- dialog --title "FORMATTING" --infobox "Formatting $ROOT_DEVICE \n\
- Size in 1K blocks: $ROOT_SIZE \n\
- Filesystem type: $ROOT_SYS_TYPE \n\
- $INODE_DENSITY " 6 45
- if mount | fgrep $ROOT_DEVICE 1> /dev/null 2> /dev/null ; then
- umount $ROOT_DEVICE 2> /dev/null
- fi
- if [ "$ROOT_SYS_TYPE" = "ext2" ]; then
- if [ "$DOFORMAT" = "Check" ]; then
- mke2fs -c -i $DENSITY $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
- else
- mke2fs -i $DENSITY $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
- fi
- else
- if [ "$DOFORMAT" = "Check" ]; then
- mkxfs -c $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
- else
- mkxfs $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
- fi
- fi
- fi
- sync
- mount -t $ROOT_SYS_TYPE $ROOT_DEVICE $T_PX 1> /dev/null 2> /dev/null
- echo "$ROOT_DEVICE / $ROOT_SYS_TYPE defaults 1 1" > /tmp/SeTnative
- break;
- else # device not tagged Linux native
- dialog --title "INCORRECT PARTITION TYPE" --msgbox "The partition you have selected is not tagged as Linux \
- native. Either select a new partition, or tag the selected \
- one with Linux fdisk." 10 50
- if [ $? = 255 ]; then
- exit
- fi
- continue;
- fi
- break;
- done # mounting the target root partition
- # Now, if the user wants to mount some other partitions for /usr or
- # /usr/X11 or whatever (/tmp, you name it), Here's where we do that
- if [ ! "`echo "$PARTLIST" | sed -n '2 p'`" = "" ]; then
- dialog --yesno "You seem to have more than one partition tagged as Linux \
- native. You may use these to distribute your Linux system across more than \
- one partition. Currently, you have $ROOT_DEVICE mounted as your / partition. \
- You might want to mount large directories such as /usr or /usr/X11 or seperate \
- partitions. You should not try to mount /etc, /sbin, or /bin on their own \
- partitions since they contain utilities needed to bring the system up and mount \
- partitions. Would you like to use some of the other Linux partitions to mount \
- some of your directories?" 14 70
- if [ $? = 0 ]; then
- while [ 0 ]; do
- echo > /tmp/tmpmsg
- echo "These are your Linux partitions:" >> /tmp/tmpmsg
- echo "$PARTLIST" >> /tmp/tmpmsg
- echo >> /tmp/tmpmsg
- echo "These partitions are already in use:" >> /tmp/tmpmsg
- mount | fgrep mnt >> /tmp/tmpmsg
- echo >> /tmp/tmpmsg
- echo "Please enter the partition you would like to use, or" >> /tmp/tmpmsg
- echo "type [q] to quit adding new partitions: " >> /tmp/tmpmsg
- dialog --inputbox "`cat /tmp/tmpmsg`" 22 73 2> /tmp/nextp
- if [ $? = 1 -o $? = 255 ]; then
- break;
- 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 --msgbox "Invalid device. Try again. Use a format such as: \
- /dev/hda3 or whatever the device name is." 7 50
- continue;
- else
- if fdisk -l | fgrep "Linux native" | fgrep $NEXT_PARTITION 1> /dev/null 2> /dev/null ; then
- NEXT_SIZE="`fdisk -l | fgrep "$NEXT_PARTITION" | cut -b38-45 2> /dev/null`"
- # dialog --menu "What type of filesystem would you like to use?" 9 70 2 \
- #"ext2" "Linux Second Extended Filesystem" \
- #"xiafs" "Linux Xiafs" 2> /tmp/filesys
- # if [ $? = 1 -o $? = 255 ]; then
- # exit
- # fi
- # NEXT_SYS_TYPE="`cat /tmp/filesys`"
- NEXT_SYS_TYPE=ext2
- rm -f /tmp/filesys
- dialog --menu "Would you like to format this partition?" 10 70 3 \
- "Format" "Quick format with no bad block checking" \
- "Check" "Slow format that checks for bad blocks" \
- "No" "No, do not format this partition" 2> /tmp/format
- if [ $? = 1 -o $? = 255 ]; then
- exit
- fi
- DOFORMAT="`cat /tmp/format`"
- rm -f /tmp/format
- if [ "$DOFORMAT" = "Format" -o "$DOFORMAT" = "Check" ]; then
- if [ "$NEXT_SYS_TYPE" = "ext2" ]; then
- dialog --title "SELECT INODE DENSITY" --menu "Ext2fs defaults to one \
- inode per 4096 bytes of drive space. If you're going to have many small files \
- on your drive, then you may need more inodes (one is used for each file \
- entry). You can change the density to one inode per 2048 bytes, or even per \
- 1024 bytes. Select '2048' or '1024', or just hit enter to accept the default \
- of 4096 bytes." 15 65 3 \
- "4096" "1 inode per 4096 bytes. (default)" \
- "2048" "1 inode per 2048 bytes." \
- "1024" "1 inode per 1024 bytes." 2> /tmp/density
- DENSITY="`cat /tmp/density`"
- rm -f /tmp/density
- if [ ! "$DENSITY" = "2048" -a ! "$DENSITY" = "1024" ]; then
- DENSITY=4096
- fi
- INODE_DENSITY="Inode density: 1 inode per $DENSITY bytes."
- fi
- dialog --title "FORMATTING" --infobox "Formatting $NEXT_PARTITION \n\
- Size in 1K blocks: $NEXT_SIZE \n\
- Filesystem type: $NEXT_SYS_TYPE \n\
- $INODE_DENSITY " 6 45
- if [ "$NEXT_SYS_TYPE" = "ext2" ]; then
- if [ "$DOFORMAT" = "Check" ]; then
- mke2fs -c -i $DENSITY $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
- else
- mke2fs -i $DENSITY $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
- fi
- else
- if [ "$DOFORMAT" = "Check" ]; then
- mkxfs -c $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
- else
- mkxfs $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
- fi
- fi
- fi
- dialog --inputbox \
- "Now this new partition must be mounted somewhere somewhere in \n\
- your new directory tree. For example, if you want to put it under \n\
- /usr/X11R6, then respond: /usr/X11R6 \n\n\
- Where would you like to mount $NEXT_PARTITION?" 12 70 2> /tmp/newdir
- NEW_DIRECTORY="`cat /tmp/newdir`"
- rm -f /tmp/newdir
- mkdir -p /mnt$NEW_DIRECTORY
- chmod 755 /mnt$NEW_DIRECTORY
- sync
- mount -t $NEXT_SYS_TYPE $NEXT_PARTITION /mnt$NEW_DIRECTORY 1> /dev/null 2> /dev/null
- echo "$NEXT_PARTITION $NEW_DIRECTORY $NEXT_SYS_TYPE defaults 1 1" >> /tmp/SeTnative
- echo > /tmp/tmpmsg
- echo "This line will be added to your /etc/fstab:" >> /tmp/tmpmsg
- echo >> /tmp/tmpmsg
- echo "$NEXT_PARTITION $NEW_DIRECTORY $NEXT_SYS_TYPE defaults 1 1" >> /tmp/tmpmsg
- echo >> /tmp/tmpmsg
- echo "Would you like to mount some more additional partitions? " >> /tmp/tmpmsg
- dialog --title "MOUNT MORE PARTITIONS?" --yesno "`cat /tmp/tmpmsg`" 15 73
- REPLY=$?
- if [ "$REPLY" = "1" ]; then
- break;
- fi
- else # device not tagged Linux native
- dialog --title "NOT LINUX NATIVE" --msgbox "The partition you have selected is not tagged as Linux \
- native. Either select a new partition, or tag the selected \
- one with Linux fdisk." 10 40
- continue;
- fi
- fi
- done # mounting additional partitions
- fi # Do you want to use these?
- fi # more than one native partition
-