#!/bin/sh # SeTpartition user-friendly rewrite Fri Dec 15 13:17:40 CST 1995 pjv # More updates for Slackware 3.5: Wed Apr 29 22:43:28 CDT 1998 # Updated for Slackware 7.x (new fdisk tags) Fri Sep 10 13:17:18 CDT 1999 export TEXTDOMAIN=slint LANG=$( $TMP/ntfs_security if [ ! $? = 0 ]; then rm -f $TMP/ntfs_security $TMP/mount-point $TMP/SeTDOS echo 1 fi } fat_security() { rm -f $TMP/fat_security dialog --visit-items --backtitle "`eval_gettext "Setting permissions on FAT partition \\\$DOS_PART"`" \ --title "`eval_gettext "SET SECURITY FOR FAT PARTITION \\\$DOS_PART"`" \ --default-item "fmask=177,dmask=077" \ --menu "`eval_gettext "Because users could go snooping through (or destroy, depending on \ the settings) your Windows partition, you should choose how much access would you \ like your non-root users to have to partition \\\$DOS_PART. The access level can \ range from no access at all, to read-only for everyone, to read-write access \ for every user on the machine. A reasonable default (read-write for root only) \ is chosen, but you may set this any way that you like."`" \ 18 80 4 \ "fmask=177,dmask=077" "`gettext "Root has read/write access, users have no access"`" \ "fmask=333,dmask=222" "`gettext "Everyone has read only access"`" \ "fmask=133,dmask=022" "`gettext "Everyone has read access, but only root can write"`" \ "fmask=111,dmask=000" "`gettext "All users can read/write to any file"`" \ 2> $TMP/fat_security if [ ! $? = 0 ]; then rm -f $TMP/fat_security $TMP/mount-point $TMP/SeTDOS echo 1 fi } # Since the USB installers (both usbboot.img and the ones created using # usbimg2disk.sh) present bogus FAT/NTFS partitions, we need a way to # filter these from the partition scan. To do this, we'll set a variable # $BANHAMMER that contains the name of the device the stick was found on. # First, we'll set that to contain some random nonsense that will never # be an actual device since reverse grepping for "" won't work. BANHAMMER="0xFE11C1A" # Look for the usbboot.img stick: if [ -L /dev/disk/by-label/USBSLACK ]; then BANHAMMER="$(readlink -f /dev/disk/by-label/USBSLACK)" fi # Look for the usbimg2disk.sh stick: if [ -L /dev/disk/by-label/USBSLACKINS ]; then BANHAMMER="$(readlink -f /dev/disk/by-label/USBSLACKINS | cut -b 1-8)" fi # Restrict the "DOS" partitions to those including a file system that we # can mount. # Also, exclude the EFI system partitions. # The UEFI specification states that the GUID of an ESP is # C12A7328-F81F-11D2-BA4B-00A0C93EC93B for a GPT layout. # In case of a DOS layout instead, the ESP OS type of the ESP is 0xEF. # lsblk writes these values in the same field: PARTTYPE. ESPPARTTYPE=C12A7328-F81F-11D2-BA4B-00A0C93EC93B OSTYPE=0xEF DOSLIST=$(lsblk -l -o name,parttype,fstype|grep -e vfat$ -e msdos$ -e ntfs$|\ grep -i -v -e "$BANHAMMER" -e $ESPPARTTYPE -e $OSTYPE|\ sed "s/ \{1,\}.*//;s,^,/dev/,"|sort) if [ "$DOSLIST" = "" ]; then # no FAT or NTFS partitions exit fi dialog --backtitle "`gettext "Setting up non-Linux partitions."`" \ --title "`gettext "FAT or NTFS PARTITIONS DETECTED"`" \ --yesno "`gettext "Partitions of type FAT or NTFS (commonly used by DOS and \ Windows) have been found on your \ system. Would you like to add these partitions to your /etc/fstab \ so that these partitions are visible from Linux?"`" \ 8 70 if [ ! $? = 0 ]; then exit fi while [ 0 ]; do # main partition selection loop rm -f $TMP/SeTSKIP echo "true" > $TMP/SeTSKIP echo -n 'dialog --visit-items --backtitle "' > $TMP/tempscript gettext "Selecting non-Linux partitions." >> $TMP/tempscript echo -n '" --title "' >> $TMP/tempscript gettext "SELECT PARTITION TO ADD TO /etc/fstab" >> $TMP/tempscript echo -n '" --ok-label "' >> $TMP/tempscript gettext "Select" >> $TMP/tempscript echo -n '" --cancel-label "' >> $TMP/tempscript gettext "Continue" >> $TMP/tempscript echo -n '" --menu "' >> $TMP/tempscript gettext "In order to make these partitions visible from Linux, we \ need to add them to your /etc/fstab. Please pick a partition to \ add to /etc/fstab, or select '---' to continue with the installation \ process." >> $TMP/tempscript echo -n '" 15 80 5 ' >> $TMP/tempscript echo "$DOSLIST" | while read NAME; do SIZE=`get_part_size $NAME` SHORTNAME=$(echo $NAME|sed "s,.*/,,") FSTYPE=$(lsblk -l -o name,fstype|grep $SHORTNAME|sed "s/[^[:space:]]*[[:space:]]*//") if [ "$FSTYPE" = "" ]; then continue fi if cat $TMP/SeTDOS | grep $NAME 1> $NDIR 2> $NDIR ; then ON=`cat $TMP/SeTDOS | grep $NAME | crunch | cut -f 2 -d ' '` echo "\"(`gettext "IN USE"`)\" \"$NAME `gettext "on"` $ON $FSYPE ${SIZE}\" \\" >> $TMP/tempscript else if [ ! "$NAME" = "$ESP" ]; then echo -n "\"$NAME\" \"$FSTYPE ${SIZE}\" " >> $TMP/tempscript echo "false" > $TMP/SeTSKIP fi fi done echo "\"---\" \"(`gettext "done, continue with setup"`)\" \\" >> $TMP/tempscript echo "\"---\" \"(`gettext "done, continue with setup"`)\" \\" >> $TMP/tempscript echo "\"---\" \"(`gettext "done, continue with setup"`)\" \\" >> $TMP/tempscript echo "\"---\" \"(`gettext "done, continue with setup"`)\" \\" >> $TMP/tempscript echo "\"---\" \"(`gettext "done, continue with setup"`)\" \\" >> $TMP/tempscript echo -n "2> $TMP/return" >> $TMP/tempscript if [ "`cat $TMP/SeTSKIP`" = "true" ]; then break fi . $TMP/tempscript if [ ! $? = 0 ]; then rm $TMP/tempscript exit 255 # user abort fi DOS_PART="`cat $TMP/return`" rm -f $TMP/tempscript if [ "$DOS_PART" = "---" ]; then break elif [ "$DOS_PART" = "(`gettext "IN USE"`)" ]; then continue fi SHORTNAME=$(echo $DOS_PART|sed "s,.*/,,") FSTYPE=$(lsblk -l -o name,fstype|grep $SHORTNAME|sed "s/[^[:space:]]*[[:space:]]*//") if [ "$FSTYPE" = "ntfs" ] ; then ntfs_security FS_UMASK="$(cat $TMP/ntfs_security)" if [ "$FS_UMASK" = "1" ]; then exit 1 else if [ "$FS_UMASK" = "fmask=333,dmask=222" ]; then FS_TYPE=ntfs else FS_TYPE=ntfs-3g fi fi else FS_TYPE=vfat fat_security FS_UMASK="$(cat $TMP/fat_security)" fi dialog --backtitle "`eval_gettext "Selecting a location to mount \\\$DOS_PART."`" \ --title "`eval_gettext "PICK MOUNT POINT FOR \\\$DOS_PART"`" \ --inputbox "`eval_gettext "Now this 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 \ enter /fat-c or /fat-d or something similar. \ NOTE: This partition will not actually be mounted until you reboot. \ Where would you like to mount \\\$DOS_PART?"`" \ 13 80 2> $TMP/mount-point if [ ! $? = 0 ]; then rm -f $TMP/tempmsg $TMP/mount-point $TMP/SeTDOS exit fi NEW_DIR="`cat $TMP/mount-point`" rm -f $TMP/mount-point # If this was left blank or is '/', drop back to the first menu and start over. if [ "$NEW_DIR" = "" -o "$NEW_DIR" = "/" ]; then continue fi if [ ! "`echo $NEW_DIR | cut -b1`" = "/" ]; then NEW_DIR="/$NEW_DIR" fi mkdir -p /mnt$NEW_DIR chmod 755 /mnt$NEW_DIR if echo "$DOSLIST" | grep $DOS_PART | grep NTFS 1> $NDIR 2> $NDIR ; then printf "%-16s %-16s %-11s %-16s %-3s %s\n" "$DOS_PART" "$NEW_DIR" "$FS_TYPE" "$FS_UMASK" "1" "0" >> $TMP/SeTDOS else printf "%-16s %-16s %-11s %-16s %-3s %s\n" "$DOS_PART" "$NEW_DIR" "$FS_TYPE" "$FS_UMASK" "1" "0" >> $TMP/SeTDOS fi done # partition adding loop rm -f $TMP/SeTSKIP gettext " Adding this information to your /etc/fstab: " > $TMP/tempmsg cat $TMP/SeTDOS >> $TMP/tempmsg dialog --backtitle "`gettext "Finished setting up non-Linux partitions."`" \ --title "`gettext "DONE ADDING FAT or NTFS PARTITIONS"`" \ --exit-label OK \ --textbox $TMP/tempmsg 15 80