home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #shell to start MToolsFM file manager.
- #(c) copyright Barry Kauler 2004,2005 www.goosee.com/puppy
-
- #can cause bugs if exists...
- rm -f /root/.mtoolsfm
-
- # #ff00ff is purple.
- xmessage -center -bg "orange" -title "MToolsFM" -buttons "" "Wait a moment, hardware probing..." &
- #check for once-only stuff...
- CDRIVE=""
- if [ -s /etc/vfathardpartition ];then
- CDRIVE="`cat /etc/vfathardpartition`"
- else
- #now probe for hard drive vfat partition... (C:)
- CDRIVE="`probepart | grep "vfat" | grep -v "/dev/sd" | head -n 1 - | cut -f 1 -d '|'`"
- #...there may be more than one!
- if [ "$CDRIVE" = "" ];then
- CDRIVE="`probepart | grep "msdos" | grep -v "/dev/sd" | head -n 1 - | cut -f 1 -d '|'`"
- fi
- if [ "$CDRIVE" = "" ];then
- #ok, desparate. no msdos/vfat h.d...
- rm -f /etc/vfathardpartition 2> /dev/null
- fi
- fi
- if [ ! "$CDRIVE" = "" ];then
- echo -n "$CDRIVE" > /etc/vfathardpartition
- LETTERC="c"
- CINFO=" c: is a vfat partition at $CDRIVE
- "
- fi
- #find any unplugged drives...
- UNPLUGGEDUSBS="`probepart 2>&1 | grep "error" | grep "dev/sd" | cut -f 8 -d " "`"
- #v1.0.0 see if the hardware has usb...
- cat /proc/pci | grep -i "usb" > /dev/null
- if [ $? -eq 0 ];then
- if [ "`lsmod | grep "usb\-storage" | head -n 1 | tr -s " " | cut -f 1 -d " " | grep "usb\-storage"`" = "" ];then
- xmessage -bg "#ff00ff" -title "Puppy drive mounter" -center -buttons "" "Please wait for the usb-storage driver to load...
-
- Note: if this windows stays here for more than a few seconds,
- it means that your PC probably has a USB1 interface, which is
- very slow to initialise. Please wait..." &
- modprobe usb-storage
- fi
- fi
- killall xmessage
-
-
- #find any Zip drive...
- ZIPFND="`probedisk | grep -i "zip"`"
- if [ ! "$ZIPFND" = "" ];then
- ZIPDRIVE="`echo "$ZIPFND" | head -n 1 - | cut -f 1 -d '|'`"
- #will only get this if disk plugged in...
- ZIPPARTNUM="`disktype $ZIPDRIVE | grep "Partition" | cut -f 1 -d ":" | cut -f 2 -d " "`"
- if [ "$ZIPPARTNUM" = "" ];then
- ZIPPARTNUM="4"
- fi
- fi
-
- #is there a floppy drive? (A:)
- ADRIVE=""
- #dmesg | grep "fd0"
- if [ "`disktype /dev/fd0 2>&1 | grep "No such device"`" = "" ];then
- #if [ $? -eq 0 ];then
- ADRIVE="/dev/fd0"
- LETTERA="a"
- AINFO=" a: is the floppy drive at /dev/fd0
- "
- fi
-
- #let's say that a card is plugged into one of these...
- USBDRIVE="`probedisk | grep "/dev/sdb" | cut -f 1 -d '|'`"
- if [ ! "$USBDRIVE" = "" ];then
- #this only works if card plugged in...
- USBPARTNUM="`disktype /dev/sdb|grep "Partition"|head -n 1 - |cut -f 1 -d ":"|cut -f 2 -d " "`"
- fi
- if [ "$USBPARTNUM" = "" ];then
- USBDRIVE="`probedisk | grep "/dev/sda" | cut -f 1 -d '|'`"
- USBPARTNUM="1" #just assume this.
- fi
- if [ ! "`echo "$UNPLUGGEDUSBS" | grep "$USBDRIVE"`" = "" ];then
- USBDRIVE=""
- USBPARTNUM=""
- fi
-
- #is there a usb drive/card reader, or Zip? (B:)
- BDRIVE=""
- if [ ! "$USBDRIVE" = "" ];then
- BDRIVE="${USBDRIVE}${USBPARTNUM}"
- LETTERB="b"
- BINFO=" b: is a USB partition at $BDRIVE
- "
- else
- #what about a zip drive?
- if [ ! "$ZIPFND" = "" ];then
- BDRIVE="${ZIPDRIVE}${ZIPPARTNUM}"
- LETTERB="b"
- BINFO=" b: is a Zip partition at $BDRIVE
- "
- fi
- fi
-
- #is there a zip drive? (D:)
- if [ ! "$USBDRIVE" = "" ];then #means usb drive has grabbed B:.
- if [ ! "$ZIPFND" = "" ];then
- DDRIVE="${ZIPDRIVE}${ZIPPARTNUM}"
- LETTERD="d"
- DINFO=" d: is a Zip partition at $DDRIVE
- "
- fi
- fi
-
- #need to write to /etc/mtools.conf and /etc/mtoolsfm.conf...
-
- echo "#Configuration file for MTools. Generated by /usr/local/bin/mtoolsfmshell" > /etc/mtools.conf
- echo "# " >> /etc/mtools.conf
-
- if [ ! "$ADRIVE" = "" ];then
- echo "drive a: file=\"/dev/fd0\" exclusive" >> /etc/mtools.conf
- fi
- if [ ! "$BDRIVE" = "" ];then
- echo "drive b: file=\"${BDRIVE}\"" >> /etc/mtools.conf
- fi
- if [ ! "$CDRIVE" = "" ];then
- echo "drive c: file=\"${CDRIVE}\"" >> /etc/mtools.conf
- fi
- if [ ! "$DDRIVE" = "" ];then
- echo "drive d: file=\"$DDRIVE\"" >> /etc/mtools.conf
- fi
-
- echo "#Configuration for MToolsFM. Generated by /usr/local/bin/mtoolsfmshell" > /etc/mtoolsfm.conf
- echo "# " >> /etc/mtoolsfm.conf
- echo "DRIVES=\"${LETTERA}${LETTERB}${LETTERC}${LETTERD}\"" >> /etc/mtoolsfm.conf
- if [ "$BDRIVE" ];then
- echo "LEFTDRIVE=\"b\"" >> /etc/mtoolsfm.conf
- else
- if [ "$ADRIVE" ];then
- echo "LEFTDRIVE=\"a\"" >> /etc/mtoolsfm.conf
- else
- echo "LEFTDRIVE=\"c\"" >> /etc/mtoolsfm.conf
- fi
- fi
- echo "RIGHTDRIVE=\" \"" >> /etc/mtoolsfm.conf
-
-
- sync #important I think
- /usr/local/bin/MToolsFM &
- MTINFO="These are the drive letters used by MToolsFM:
- ${AINFO}${BINFO}${CINFO}${DINFO}
- MToolsFM does NOT need these to be mounted!"
- xmessage -timeout 120 -bg "#ff00ff" -title "MToolsFM information" -buttons "" "$MTINFO" &
-