home *** CD-ROM | disk | FTP | other *** search
- #! /bin/bash
- # (c) Copyright 2003/2004/2005/2006 Barry Kauler www.puppylinux.com
- # This script has a GUI to mount and unmount partitions.
- # Oct 2005 total rewrite.
- # v1.0.7 Nov 2005: bugfix by GuestToo.
- # Jan 2006 updated for Puppy2.
-
- # Note:
- # The mount* program normally saves info on what is mounted
- # in /etc/mtab and /proc/mounts, however these files are
- # not used in Puppy ... (turned off in Busybox)
- # Anyway, just executing "mount" returns the info.
-
- # i want to use eject* to eject removable media, but this
- # reads /etc/mtab ...so, I'll write to mtab in this script!
-
- fsfunc() #f.s. type param passed in
- {
- FSTYPE="$1"
- [ "$FSTYPE" = "Ext2" ] && FSTYPE="ext2"
- [ "$FSTYPE" = "ReiserFS" ] && FSTYPE="reiserfs"
- [ "$FSTYPE" = "Ext3" ] && FSTYPE="ext3"
- [ "$FSTYPE" = "FAT12" ] && FSTYPE="vfat"
- [ "$FSTYPE" = "FAT16" ] && FSTYPE="vfat"
- [ "$FSTYPE" = "FAT32" ] && FSTYPE="vfat"
- [ "$FSTYPE" = "NTFS" ] && FSTYPE="ntfs"
- [ "$FSTYPE" = "ISO9660" ] && FSTYPE="iso9660"
- }
-
- #see if the hardware has usb...
- cat /proc/pci | grep -i "usb" > /dev/null
- if [ $? -eq 0 ];then
- #k2.6 module is usb-storage.ko but lsmod shows it as usb_storage!!!...
- if [ "`lsmod | grep --extended-regexp 'usb\-storage|usb_storage' | head -n 1 | tr -s " " | cut -f 1 -d " " | grep --extended-regexp 'usb\-storage|usb_storage'`" = "" ];then
- xmessage -bg "#ff00ff" -title "Puppy drive mounter" -center -buttons "" "Please wait for the usb-storage driver to load...
-
- Note: A USB1 interface takes longer to initialise than a USB2 interface,
- in the former case up to 25 seconds, in the latter about 4 seconds." &
- XPID=$!
- #v2.0.0
- modprobe usb-storage &
- sleep 6
- [ "`cat /proc/pci | grep -i "usb" | grep "Controller" | grep '2\.[0-9]'`" = "" ] && sleep 20
- kill $XPID
- fi
- fi
-
- #/usr/sbin/disk.tcl & #displays partition sizes graphically.
- #X0PID=$!
-
-
- while :; do #BIGLOOP
-
- xmessage -bg "orange" -buttons "" -title "Puppy drive mounter" "Please wait, probing hardware..." &
- X1PID=$!
-
- DISKINFO="`probedisk 2> /tmp/probediskerr.txt`"
- PARTINFO="`probepart -m 2> /tmp/probeparterr.txt | grep "/dev/" | grep -v '|swap|' | grep --extended-regexp "ext2|ext3|reiserfs|msdos|vfat|ntfs|NTFS|iso9660"`"
-
- #v2.0.0
- #a drive could be a "superfloppy", with no mbr and no partitions...
- #remove partition entries from PARTINFO, replace with one entry...
- for ONEDRIVE in `echo "$DISKINFO" | cut -f 1 -d '|' | tr "\n" " "`
- do
- DISKTYPE="`disktype /dev/$ONEDRIVE 2> /dev/null`"
- SUPERFLOPPYFS="`echo "$DISKTYPE" | grep "file system" | grep "^[a-zA-Z]" | head -n 1 | cut -f 1 -d " "`"
- if [ "$SUPERFLOPPYFS" ];then
- fsfunc $SUPERFLOPPYFS #returns FSTYPE
- SUPERSIZM="`echo "$DISKTYPE" | grep "Block device" | tr -s " " | cut -f 4 -d " "`"
- PARTTMP="`echo "$PARTINFO" | grep -v "/dev/$ONEDRIVE"`"
- PARTINFO="$PARTTMP
- /dev/${ONEDRIVE}|${FSTYPE}|${SUPERSIZM}|Superfloppy drive"
- fi
- done
-
-
- #one tricky thing about probedisk is it returns both ide and scsi names for scsi-emulated drive...
- #if cd/dvd drive is scsi-emul, screen out the line with ide name...
- if [ -f /etc/cdburnerdevice ];then
- BURNERDEVICE="/dev/`cat /etc/cdburnerdevice`"
- if [ -f /etc/scsiemul ];then
- if [ "`cat /etc/scsiemul`" = "on" ];then
- TITLESTRING="`echo "$DISKINFO" | grep "$BURNERDEVICE" | cut -f 3 -d '|'`"
- IDEDEVICE="`echo "$DISKINFO" | grep "$TITLESTRING" | grep -v "$BURNERDEVICE" | head -n 1 | cut -f 1 -d '|'`"
- [ "$IDEDEVICE" ] && DISKINFO="`echo -n "$DISKINFO" | grep -v "$IDEDEVICE"`"
- fi
- fi
- fi
-
- kill $X1PID
-
- #if a removable drive is mounted, check that it hasn't been removed...
- if [ -z /tmp/probeparterr.txt ];then
- ERRDEVS="`cat /tmp/probeparterr.txt | grep "libcfdisk" | cut -f 3 -d '/'`"
- for AERRDEV in $ERRDEVS
- do
- if [ ! "`mount | grep "/dev/$AERRDEV"`" = "" ];then
- DRVDEV="/dev/`echo -n "$AERRDEV" | cut -b 1-3`"
- DRVDESCR="`echo "$DISKINFO" | grep "$DRVDEV" | cut -f 3 -d '|'`"
- xmessage -bg "#ff8080" -title "Puppy drive mounter: ERROR" -center "
- You have unplugged drive /dev/$AERRDEV while it is still mounted.
- Drive description: $DRVDESCR
-
- A removable drive must always be unmounted before being removed.
-
- Plug the drive back in RIGHT NOW, then click OK button..."
- fi
- done
- fi
-
- DIALOGMAIN="
- <wtitle>Puppy drive mounter</wtitle>
- <vbox>
- "
-
- #######FLOPPY###########
- if [ ! "`cat /var/log/messages | grep "Floppy drive" | grep "fd0"`" = "" ];then
- DEVFD0="/dev/fd0"
- MNTFD0="`mount | grep "/dev/fd0" | cut -f 3 -d ' '`"
- DIALOGMAIN="$DIALOGMAIN <frame Floppy drive>"
- if [ "$MNTFD0" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on /mnt/floppy
- DO NOT REMOVE FLOPPY\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>/dev/fd0</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/floppy24green.xpm</input>
- <action>Exit:/dev/fd0_/mnt/floppy_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>/dev/fd0</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/floppy24red.xpm</input>
- <action>Exit:/dev/fd0_/mnt/floppy_RED</action>
- </button>
- </hbox>"
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- #######END FLOPPY###########
-
- #v2.0.0
- #######ZIP/LS120 IDE FLOPPY###########
- if [ ! "`cat /var/log/messages | grep "ATAPI FLOPPY"`" = "" ];then
- ZIPDISK="`echo "$DISKINFO" | grep '|floppy|' | grep "ATAPI" | cut -f 1 -d '|'`"
- ZIPNUM="`disktype $ZIPDISK | grep '^Partition ' | cut -f 1 -d ':' | cut -f 2 -d " "`"
- DEVZIP="$ZIPDISK$ZIPNUM" #ex: /dev/hdd4
- MNTZIP="/mnt/`echo -n "$DEVZIP" | cut -f 3 -d '/'`"
- FSZIP="`disktype $DEVZIP | grep 'file system' | cut -f 1 -d " "`" #ex: FAT16
- fsfunc $FSZIP
- FSZIP="$FSTYPE"
- XMNTZIP="`mount | grep "$DEVZIP"`"
-
- DIALOGMAIN="$DIALOGMAIN <frame Zip/LS120 ATAPI drive>"
- if [ "$XMNTZIP" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on $MNTZIP
- DO NOT REMOVE ZIP DISK\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>$DEVZIP</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/floppy24green.xpm</input>
- <action>Exit:${DEVZIP}_${MNTZIP}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>$DEVZIP</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/floppy24red.xpm</input>
- <action>Exit:${DEVZIP}_${MNTZIP}_RED</action>
- </button>
- </hbox>"
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- #######END ZIP/LS120###########
-
-
- #####CD/DVD##############
- CDROMS="`echo -n "$DISKINFO" | grep '|cdrom|'`"
- if [ "$CDROMS" ];then
- NUMLINES=`echo "$CDROMS" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && CDROM1="`echo -n "$CDROMS" | tail -n 1 | head -n 1`"
- [ $NUMLINES -eq 2 ] && CDROM2="`echo -n "$CDROMS" | tail -n 2 | head -n 1`"
- [ $NUMLINES -eq 3 ] && CDROM3="`echo -n "$CDROMS" | tail -n 3 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- fi
- if [ "$CDROM1" ];then
- DEVCDR1="`echo -n "$CDROM1" | cut -f 1 -d '|'`"
- DESCRCDR1="`echo -n "$CDROM1" | cut -f 3 -d '|'`"
- MNTCDR1="`mount | grep "$DEVCDR1" | cut -f 3 -d ' '`"
- FSCDR1="`echo "$PARTINFO" | grep "$DEVCDR1" | cut -f 2 -d '|'`"
- DVDRWMEDIAINFO="`dvd+rw-mediainfo $DEVCDR1 2>&1`"
- MEDIACDR1="DVD"
- [ ! "`echo -n "$DVDRWMEDIAINFO" | grep --extended-regexp "non\\-DVD|not a DVD unit"`" = "" ] && MEDIACDR1="CD"
- DIALOGMAIN="$DIALOGMAIN <frame $MEDIACDR1 $DEVCDR1, $DESCRCDR1>"
- if [ "$MNTCDR1" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on $MNTCDR1
- DO NOT EJECT MEDIA\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>$DEVCDR1</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/cd24green.xpm</input>
- <action>Exit:${DEVCDR1}_${MNTCDR1}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>$DEVCDR1</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/cd24red.xpm</input>
- <action>Exit:${DEVCDR1}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- if [ "$CDROM2" ];then
- DEVCDR2="`echo -n "$CDROM2" | cut -f 1 -d '|'`"
- DESCRCDR2="`echo -n "$CDROM2" | cut -f 3 -d '|'`"
- MNTCDR2="`mount | grep "$DEVCDR2" | cut -f 3 -d ' '`"
- FSCDR2="`echo "$PARTINFO" | grep "$DEVCDR2" | cut -f 2 -d '|'`"
- DVDRWMEDIAINFO="`dvd+rw-mediainfo $DEVCDR2 2>&1`"
- MEDIACDR2="DVD"
- [ ! "`echo -n "$DVDRWMEDIAINFO" | grep --extended-regexp "non\\-DVD|not a DVD unit"`" = "" ] && MEDIACDR2="CD"
- DIALOGMAIN="$DIALOGMAIN <frame $MEDIACDR2 $DEVCDR2, $DESCRCDR2>"
- if [ "$MNTCDR2" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on $MNTCDR2
- DO NOT EJECT MEDIA\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>$DEVCDR2</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/cd24green.xpm</input>
- <action>Exit:${DEVCDR2}_${MNTCDR2}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>$DEVCDR2</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/cd24red.xpm</input>
- <action>Exit:${DEVCDR2}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- #########CD/DVD##########
-
- #########HARD DRIVE###########
- DISKS="`echo -n "$DISKINFO" | grep '|disk|'`"
- if [ "$DISKS" ];then
- NUMLINES=`echo "$DISKS" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && DISK1="`echo -n "$DISKS" | tail -n 1 | head -n 1`"
- [ $NUMLINES -eq 2 ] && DISK2="`echo -n "$DISKS" | tail -n 2 | head -n 1`"
- [ $NUMLINES -eq 3 ] && DISK3="`echo -n "$DISKS" | tail -n 3 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- fi
-
- if [ "$DISK1" ];then
- DEVDISK1="`echo -n "$DISK1" | cut -f 1 -d '|'`"
- DESCRDISK1="`echo -n "$DISK1" | cut -f 3 -d '|'`"
- INFODISK1="`fdisk -l $DEVDISK1 | head -n 2 | tail -n 1 | cut -f 1 -d ','`"
- DIALOGMAIN="$DIALOGMAIN <frame $INFODISK1, $DESCRDISK1>"
- PARTSDISK1="`echo "$PARTINFO" | grep "$DEVDISK1"`"
- if [ "$PARTSDISK1" ];then
- NUMLINES=`echo "$PARTSDISK1" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && PART1DISK1="`echo -n "$PARTSDISK1" | tail -n 1 | head -n 1`"
- [ $NUMLINES -eq 2 ] && PART2DISK1="`echo -n "$PARTSDISK1" | tail -n 2 | head -n 1`"
- [ $NUMLINES -eq 3 ] && PART3DISK1="`echo -n "$PARTSDISK1" | tail -n 3 | head -n 1`"
- [ $NUMLINES -eq 4 ] && PART4DISK1="`echo -n "$PARTSDISK1" | tail -n 4 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- if [ "$PART1DISK1" ];then
- DEVP1D1="`echo -n "$PART1DISK1" | cut -f 1 -d '|'`"
- MNTP1D1="`mount | grep "$DEVP1D1" | cut -f 3 -d ' '`"
- FSP1D1="`echo "$PARTINFO" | grep "$DEVP1D1" | cut -f 2 -d '|'`"
- SIZEP1D1="`echo "$PARTINFO" | grep "$DEVP1D1" | cut -f 3 -d '|'`"
- if [ "$MNTP1D1" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP1D1\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP1D1
- ${SIZEP1D1}M $FSP1D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP1D1}_${MNTP1D1}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP1D1
- ${SIZEP1D1}M $FSP1D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP1D1}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- if [ "$PART2DISK1" ];then
- DEVP2D1="`echo -n "$PART2DISK1" | cut -f 1 -d '|'`"
- MNTP2D1="`mount | grep "$DEVP2D1" | cut -f 3 -d ' '`"
- FSP2D1="`echo "$PARTINFO" | grep "$DEVP2D1" | cut -f 2 -d '|'`"
- SIZEP2D1="`echo "$PARTINFO" | grep "$DEVP2D1" | cut -f 3 -d '|'`"
- if [ "$MNTP2D1" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP2D1\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP2D1
- ${SIZEP2D1}M $FSP2D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP2D1}_${MNTP2D1}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP2D1
- ${SIZEP2D1}M $FSP2D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP2D1}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- if [ "$PART3DISK1" ];then
- DEVP3D1="`echo -n "$PART3DISK1" | cut -f 1 -d '|'`"
- MNTP3D1="`mount | grep "$DEVP3D1" | cut -f 3 -d ' '`"
- FSP3D1="`echo "$PARTINFO" | grep "$DEVP3D1" | cut -f 2 -d '|'`"
- SIZEP3D1="`echo "$PARTINFO" | grep "$DEVP3D1" | cut -f 3 -d '|'`"
- if [ "$MNTP3D1" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP3D1\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP3D1
- ${SIZEP3D1}M $FSP3D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP3D1}_${MNTP3D1}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP3D1
- ${SIZEP3D1}M $FSP3D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP3D1}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- if [ "$PART4DISK1" ];then
- DEVP4D1="`echo -n "$PART4DISK1" | cut -f 1 -d '|'`"
- MNTP4D1="`mount | grep "$DEVP4D1" | cut -f 3 -d ' '`"
- FSP4D1="`echo "$PARTINFO" | grep "$DEVP4D1" | cut -f 2 -d '|'`"
- SIZEP4D1="`echo "$PARTINFO" | grep "$DEVP4D1" | cut -f 3 -d '|'`"
- if [ "$MNTP4D1" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP4D1\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP4D1
- ${SIZEP4D1}M $FSP4D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP4D1}_${MNTP4D1}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP4D1
- ${SIZEP4D1}M $FSP4D1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP4D1}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
-
- if [ "$DISK2" ];then
- DEVDISK2="`echo -n "$DISK2" | cut -f 1 -d '|'`"
- DESCRDISK2="`echo -n "$DISK2" | cut -f 3 -d '|'`"
- INFODISK2="`fdisk -l $DEVDISK2 | head -n 2 | tail -n 1 | cut -f 1 -d ','`"
- DIALOGMAIN="$DIALOGMAIN <frame $INFODISK2, $DESCRDISK2>"
- PARTSDISK2="`echo "$PARTINFO" | grep "$DEVDISK2"`"
- if [ "$PARTSDISK2" ];then
- NUMLINES=`echo "$PARTSDISK2" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && PART1DISK2="`echo -n "$PARTSDISK2" | tail -n 1 | head -n 1`"
- [ $NUMLINES -eq 2 ] && PART2DISK2="`echo -n "$PARTSDISK2" | tail -n 2 | head -n 1`"
- [ $NUMLINES -eq 3 ] && PART3DISK2="`echo -n "$PARTSDISK2" | tail -n 3 | head -n 1`"
- [ $NUMLINES -eq 4 ] && PART4DISK2="`echo -n "$PARTSDISK2" | tail -n 4 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- if [ "$PART1DISK2" ];then
- DEVP1D2="`echo -n "$PART1DISK2" | cut -f 1 -d '|'`"
- MNTP1D2="`mount | grep "$DEVP1D2" | cut -f 3 -d ' '`"
- FSP1D2="`echo "$PARTINFO" | grep "$DEVP1D2" | cut -f 2 -d '|'`"
- SIZEP1D2="`echo "$PARTINFO" | grep "$DEVP1D2" | cut -f 3 -d '|'`"
- if [ "$MNTP1D2" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP1D2\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP1D2
- ${SIZEP1D2}M $FSP1D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP1D2}_${MNTP1D2}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP1D2
- ${SIZEP1D2}M $FSP1D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP1D2}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- if [ "$PART2DISK2" ];then
- DEVP2D2="`echo -n "$PART2DISK2" | cut -f 1 -d '|'`"
- MNTP2D2="`mount | grep "$DEVP2D2" | cut -f 3 -d ' '`"
- FSP2D2="`echo "$PARTINFO" | grep "$DEVP2D2" | cut -f 2 -d '|'`"
- SIZEP2D2="`echo "$PARTINFO" | grep "$DEVP2D2" | cut -f 3 -d '|'`"
- if [ "$MNTP2D2" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP2D2\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP2D2
- ${SIZEP2D2}M $FSP2D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP2D2}_${MNTP2D2}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP2D2
- ${SIZEP2D2}M $FSP2D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP2D2}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- if [ "$PART3DISK2" ];then
- DEVP3D2="`echo -n "$PART3DISK2" | cut -f 1 -d '|'`"
- MNTP3D2="`mount | grep "$DEVP3D2" | cut -f 3 -d ' '`"
- FSP3D2="`echo "$PARTINFO" | grep "$DEVP3D2" | cut -f 2 -d '|'`"
- SIZEP3D2="`echo "$PARTINFO" | grep "$DEVP3D2" | cut -f 3 -d '|'`"
- if [ "$MNTP3D2" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP3D2\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP3D2
- ${SIZEP3D2}M $FSP3D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP3D2}_${MNTP3D2}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP3D2
- ${SIZEP3D2}M $FSP3D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP3D2}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- if [ "$PART4DISK2" ];then
- DEVP4D2="`echo -n "$PART4DISK2" | cut -f 1 -d '|'`"
- MNTP4D2="`mount | grep "$DEVP4D2" | cut -f 3 -d ' '`"
- FSP4D2="`echo "$PARTINFO" | grep "$DEVP4D2" | cut -f 2 -d '|'`"
- SIZEP4D2="`echo "$PARTINFO" | grep "$DEVP4D2" | cut -f 3 -d '|'`"
- if [ "$MNTP4D2" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on
- $MNTP4D2\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP4D2
- ${SIZEP4D2}M $FSP4D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24green.xpm</input>
- <action>Exit:${DEVP4D2}_${MNTP4D2}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP4D2
- ${SIZEP4D2}M $FSP4D2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/hd24red.xpm</input>
- <action>Exit:${DEVP4D2}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- #########HARD DRIVE###########
-
-
- #########USB DRIVE############
- DACCS="`echo -n "$DISKINFO" | grep '|Direct\-Access|'`"
- if [ "$DACCS" ];then
- NUMLINES=`echo "$DACCS" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && DACC1="`echo -n "$DACCS" | tail -n 1 | head -n 1`"
- [ $NUMLINES -eq 2 ] && DACC2="`echo -n "$DACCS" | tail -n 2 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- fi
- CHECKA1=""
- if [ "$DACC1" ];then #in case it is removed.
- DEVDACC1="`echo -n "$DACC1" | cut -f 1 -d '|'`"
- CHECKA1="`echo "$PARTINFO" | grep "$DEVDACC1"`"
- fi
- if [ "$CHECKA1" ];then
- #DEVDACC1="`echo -n "$DACC1" | cut -f 1 -d '|'`"
- DESCRDACC1="`echo -n "$DACC1" | cut -f 3 -d '|'`"
- INFODACC1="`fdisk -l $DEVDACC1 | head -n 2 | tail -n 1 | cut -f 1 -d ','`,"
- DIALOGMAIN="$DIALOGMAIN <frame $INFODACC1 $DESCRDACC1>"
- PARTSDACC1="`echo "$PARTINFO" | grep "$DEVDACC1"`"
- if [ "$PARTSDACC1" ];then
- NUMLINES=`echo "$PARTSDACC1" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && PART1DACC1="`echo -n "$PARTSDACC1" | tail -n 1 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- if [ "$PART1DACC1" ];then
- DEVP1A1="`echo -n "$PART1DACC1" | cut -f 1 -d '|'`"
- MNTP1A1="`mount | grep "$DEVP1A1" | cut -f 3 -d ' '`"
- FSP1A1="`echo "$PARTINFO" | grep "$DEVP1A1" | cut -f 2 -d '|'`"
- SIZEP1A1="`echo "$PARTINFO" | grep "$DEVP1A1" | cut -f 3 -d '|'`"
- if [ "$MNTP1A1" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on $MNTP1A1
- DO NOT UNPLUG DRIVE\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP1A1
- ${SIZEP1A1}M $FSP1A1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/da24green.xpm</input>
- <action>Exit:${DEVP1A1}_${MNTP1A1}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP1A1
- ${SIZEP1A1}M $FSP1A1\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/da24red.xpm</input>
- <action>Exit:${DEVP1A1}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- CHECKA2=""
- if [ "$DACC2" ];then #in case it is removed.
- DEVDACC2="`echo -n "$DACC2" | cut -f 1 -d '|'`"
- CHECKA2="`echo "$PARTINFO" | grep "$DEVDACC2"`"
- fi
- if [ "$CHECKA2" ];then
- DEVDACC2="`echo -n "$DACC2" | cut -f 1 -d '|'`"
- DESCRDACC2="`echo -n "$DACC2" | cut -f 3 -d '|'`"
- INFODACC2="`fdisk -l $DEVDACC2 | head -n 2 | tail -n 1 | cut -f 1 -d ','`"
- DIALOGMAIN="$DIALOGMAIN <frame $INFODACC2, $DESCRDACC2>"
- PARTSDACC2="`echo "$PARTINFO" | grep "$DEVDACC2"`"
- if [ "$PARTSDACC2" ];then
- NUMLINES=`echo "$PARTSDACC2" | wc -l | tr -s ' ' | cut -f 2 -d ' '`
- while [ $NUMLINES -gt 0 ];do
- [ $NUMLINES -eq 1 ] && PART1DACC2="`echo -n "$PARTSDACC2" | tail -n 1 | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- done
- if [ "$PART1DACC2" ];then
- DEVP1A2="`echo -n "$PART1DACC2" | cut -f 1 -d '|'`"
- MNTP1A2="`mount | grep "$DEVP1A2" | cut -f 3 -d ' '`"
- FSP1A2="`echo "$PARTINFO" | grep "$DEVP1A2" | cut -f 2 -d '|'`"
- SIZEP1A2="`echo "$PARTINFO" | grep "$DEVP1A2" | cut -f 3 -d '|'`"
- if [ "$MNTP1A2" ];then
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"Mounted on $MNTP1A2
- DO NOT UNPLUG DRIVE\"</label></text>
- <text><label>\" \"</label></text>
- <text><label>\"$DEVP1A2
- ${SIZEP1A2}M $FSP1A2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/da24green.xpm</input>
- <action>Exit:${DEVP1A2}_${MNTP1A2}_GREEN</action>
- </button>
- </hbox>"
- else
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <text><label>\"$DEVP1A2
- ${SIZEP1A2}M $FSP1A2\"</label></text>
- <button>
- <input file>/usr/local/lib/X11/pixmaps/da24red.xpm</input>
- <action>Exit:${DEVP1A2}_XXX_RED</action>
- </button>
- </hbox>"
- fi
- fi
- fi
- DIALOGMAIN="$DIALOGMAIN </frame>"
- fi
- #########USB DRIVE############
-
- #prevent some partitions from being unmounted...
- NUMLINES=`echo "$DIALOGMAIN" | wc -l | tr -s " " | cut -f 2 -d " "`
- REDUCELIST="$DIALOGMAIN"
- while [ ! $NUMLINES -eq 0 ];do
- HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
- NUMLINES=`expr $NUMLINES - 1`
- REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`"
- if [ "`echo -n "$HEAD1ST" | grep "_GREEN"`" = "" ];then
- NEWDIALOGMAIN="$NEWDIALOGMAIN
- $HEAD1ST"
- else
- #HMNTPT="`echo -n "$HEAD1ST" | cut -f 2 -d ':' | cut -f 2 -d '_'`"
- #v2.0.0...
- HMNTPT="`echo -n "$HEAD1ST" | cut -f 2 -d ':' | cut -f 2 -d '_' | cut -f 2 -d '/'`"
- case $HMNTPT in
- #v2.0.0 replaced those below with just this...
- "initrd")
- NEWDIALOGMAIN="$NEWDIALOGMAIN
- <visible>disabled</visible>
- $HEAD1ST"
- ;;
- # "/root")
- # NEWDIALOGMAIN="$NEWDIALOGMAIN
- #<visible>disabled</visible>
- #$HEAD1ST"
- # ;;
- # "/mnt/pupxxx")
- # NEWDIALOGMAIN="$NEWDIALOGMAIN
- #<visible>disabled</visible>
- #$HEAD1ST"
- # ;;
- # "/mnt/home")
- # if [ -f /etc/multisessionmediatype ];then
- # NEWDIALOGMAIN="$NEWDIALOGMAIN
- #$HEAD1ST"
- # else
- # NEWDIALOGMAIN="$NEWDIALOGMAIN
- #<visible>disabled</visible>
- #$HEAD1ST"
- # fi
- # ;;
- *)
- NEWDIALOGMAIN="$NEWDIALOGMAIN
- $HEAD1ST"
- ;;
- esac
- fi
- done
- DIALOGMAIN="$NEWDIALOGMAIN"
-
- #bring up the gui...
- DIALOGMAIN="$DIALOGMAIN
- <hbox>
- <button><input file>/usr/local/lib/X11/mini-icons/mini-turn.xpm</input><label>REFRESH</label></button>
- <button><input file>/usr/local/lib/X11/mini-icons/mini.checkmark.xpm</input><label>QUIT</label></button>
- </hbox>
- </vbox>"
- echo "$DIALOGMAIN" > /tmp/pmountdlg.txt
- RETSTRING="`echo "$DIALOGMAIN" | gtkdialog2 --stdin`"
-
- echo "$RETSTRING" #to console
- [ ! "`echo "$RETSTRING" | grep "EXIT" | grep "abort"`" = "" ] && break #exit BIGLOOP v2.0.0
- [ ! "`echo "$RETSTRING" | grep "QUIT"`" = "" ] && break #exit BIGLOOP
-
- ABUTTON="`echo "$RETSTRING" | grep "EXIT:" | cut -f 2 -d ':'`"
- [ "$ABUTTON" = "" ] && continue #restart BIGLOOP
- ADEVICE="`echo -n "$ABUTTON" | cut -f 1 -d '_'`"
- AMNTPT="`echo -n "$ABUTTON" | cut -f 2 -d '_'`"
- ASTATUS="`echo -n "$ABUTTON" | cut -f 3 -d '_'`"
- AFSYS="`echo "$PARTINFO" | grep "$ADEVICE" | cut -f 2 -d '|'`"
- if [ "$AFSYS" = "none" ];then
- if [ ! "`echo "$PARTINFO" | grep "$ADEVICE" | grep -i "ntfs"`" = "" ];then
- AFSYS="ntfs"
- fi
- fi
- if [ "$AFSYS" = "msdos" ];then
- AFSYS="vfat"
- fi
-
- #v2.0.0
- if [ "$AFSYS" = "" ];then
- fsfunc "`disktype $ADEVICE | grep "file system" | grep "^[a-zA-Z]" | head -n 1 | cut -f 1 -d " "`"
- AFSYS="$FSTYPE"
- fi
-
- if [ "$ASTATUS" = "GREEN" ];then
- #need to unmount a partition...
- CURRENTMNT="$AMNTPT"
- rox -D "$CURRENTMNT"
- sync
- umount $ADEVICE
- FTRY=$?
- MNTATTEMPT="unmount"
- if [ $FTRY -eq 0 ];then
- [ ! "`echo -n "$CDROMS" | grep "$ADEVICE"`" = "" ] && /usr/bin/eject $ADEVICE
- fi
- else
- if [ "$AMNTPT" = "XXX" ];then
- xADEVICE="`echo -n "$ADEVICE" | cut -f 3 -d '/'`"
- AMNTPT="/mnt/$xADEVICE"
- fi
- #special case...
- if [ -f /etc/multisessionmediatype ];then
- if [ "$BURNERDEVICE" = "$ADEVICE" ];then
- [ "`mount | grep "/mnt/home"`" = "" ] && AMNTPT="/mnt/home"
- fi
- fi
- [ ! -d $AMNTPT ] && mkdir $AMNTPT
- if [ "$AFSYS" = "ntfs" ];then
- mount -r -t $AFSYS $ADEVICE $AMNTPT
- else
- mount -t $AFSYS $ADEVICE $AMNTPT
- fi
- FTRY=$?
- MNTATTEMPT="mount"
- CURRENTMNT="$AMNTPT"
- fi
-
-
- if [ ! $FTRY -eq 0 ];then #=1 if failed
- EXTRAMSG0="`fuser -v -m $CURRENTMNT`"
- if [ "$EXTRAMSG0" = "" ];then
- xmessage -bg "#ff8080" -title "Puppy drive mounter: ERROR" -center "FAILURE! In the case of removable media, the most
- common reason is the media is not currently inserted.
- If so, please remedy."
- else
- if [ "$MNTATTEMPT" = "unmount" ];then #have failed attempt to unmount...
- xmessage -bg "#ff00ff" -title "KILL, KILL..." -center -buttons KILL:10,EXIT:20 "FAILURE! One or more processes (programs) are currently
- using the partition. Here they are:
- $EXTRAMSG0
-
- If you press the \"KILL\" button, Puppy will attempt to
- kill the offending programs for you. Only do this as a
- last resort. Firstly you should try to close the programs
- manually, so do not press \"KILL\".
- PLEASE PRESS THE \"EXIT\" BUTTON!"
- if [ $? -eq 10 ];then
- fuser -k -m $CURRENTMNT
- fi
- else #have failed attempt to mount.
- xmessage -bg "#ff8080" -title "Puppy drive mounter: ERROR" -center "FAILURE! In the case of removable media, the most
- common reason is the media is not currently inserted.
- Or, you forgot to unmount the previously inserted media.
- If so, please remedy."
- fi
- fi
- else
- if [ "$MNTATTEMPT" = "mount" ];then
- #comes here if have just successfully mounted a partition.
- #launch rox
- rox -d "$CURRENTMNT" &
- fi
- fi
-
- done #BIGLOOP
-
- #killall disk.tcl
- ###END###
-