home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / local / bin / mtoolsfmshell < prev    next >
Encoding:
Text File  |  2005-03-27  |  4.5 KB  |  152 lines

  1. #!/bin/sh
  2. #shell to start MToolsFM file manager.
  3. #(c) copyright Barry Kauler 2004,2005 www.goosee.com/puppy
  4.  
  5. #can cause bugs if exists...
  6. rm -f /root/.mtoolsfm
  7.  
  8. # #ff00ff is purple.
  9. xmessage -center -bg "orange" -title "MToolsFM" -buttons "" "Wait a moment, hardware probing..." &
  10. #check for once-only stuff...
  11. CDRIVE=""
  12. if [ -s /etc/vfathardpartition ];then
  13.  CDRIVE="`cat /etc/vfathardpartition`"
  14. else
  15.  #now probe for hard drive vfat partition... (C:)
  16.  CDRIVE="`probepart | grep "vfat" | grep -v "/dev/sd" | head -n 1 - | cut -f 1 -d '|'`"
  17.  #...there may be more than one!
  18.  if [ "$CDRIVE" = "" ];then
  19.   CDRIVE="`probepart | grep "msdos"  | grep -v "/dev/sd" | head -n 1 - | cut -f 1 -d '|'`"
  20.  fi
  21.  if [ "$CDRIVE" = "" ];then
  22.   #ok, desparate. no msdos/vfat h.d...
  23.   rm -f /etc/vfathardpartition 2> /dev/null
  24.  fi
  25. fi
  26. if [ ! "$CDRIVE" = "" ];then
  27.  echo -n "$CDRIVE" > /etc/vfathardpartition
  28.  LETTERC="c"
  29.  CINFO=" c: is a vfat partition at $CDRIVE
  30. "
  31. fi
  32. #find any unplugged drives...
  33. UNPLUGGEDUSBS="`probepart 2>&1 | grep "error" | grep "dev/sd" | cut -f 8 -d " "`"
  34. #v1.0.0 see if the hardware has usb...
  35. cat /proc/pci | grep -i "usb" > /dev/null
  36. if [ $? -eq 0 ];then
  37.  if [ "`lsmod | grep "usb\-storage" | head -n 1 | tr -s " " | cut -f 1 -d " " | grep "usb\-storage"`" = "" ];then
  38.    xmessage -bg "#ff00ff" -title "Puppy drive mounter" -center -buttons "" "Please wait for the usb-storage driver to load...
  39.  
  40. Note: if this windows stays here for more than a few seconds,
  41. it means that your PC probably has a USB1 interface, which is
  42. very slow to initialise. Please wait..." &
  43.    modprobe usb-storage
  44.  fi
  45. fi
  46. killall xmessage
  47.  
  48.  
  49. #find any Zip drive...
  50. ZIPFND="`probedisk | grep -i "zip"`"
  51. if [ ! "$ZIPFND" = "" ];then
  52.  ZIPDRIVE="`echo "$ZIPFND" | head -n 1 - | cut -f 1 -d '|'`"
  53.  #will only get this if disk plugged in...
  54.  ZIPPARTNUM="`disktype $ZIPDRIVE | grep "Partition" | cut -f 1 -d ":" | cut -f 2 -d " "`"
  55.  if [ "$ZIPPARTNUM" = "" ];then
  56.   ZIPPARTNUM="4"
  57.  fi
  58. fi
  59.  
  60. #is there a floppy drive? (A:)
  61. ADRIVE=""
  62. #dmesg | grep "fd0"
  63. if [ "`disktype /dev/fd0 2>&1 | grep "No such device"`" = "" ];then
  64. #if [ $? -eq 0 ];then
  65.  ADRIVE="/dev/fd0"
  66.  LETTERA="a"
  67.  AINFO=" a: is the floppy drive at /dev/fd0
  68. "
  69. fi
  70.  
  71. #let's say that a card is plugged into one of these...
  72. USBDRIVE="`probedisk | grep "/dev/sdb" | cut -f 1 -d '|'`"
  73. if [ ! "$USBDRIVE" = "" ];then
  74.  #this only works if card plugged in...
  75.  USBPARTNUM="`disktype /dev/sdb|grep "Partition"|head -n 1 - |cut -f 1 -d ":"|cut -f 2 -d " "`"
  76. fi
  77. if [ "$USBPARTNUM" = "" ];then
  78.  USBDRIVE="`probedisk | grep "/dev/sda" | cut -f 1 -d '|'`"
  79.  USBPARTNUM="1" #just assume this.
  80. fi
  81. if [ ! "`echo "$UNPLUGGEDUSBS" | grep "$USBDRIVE"`" = "" ];then
  82.  USBDRIVE=""
  83.  USBPARTNUM=""
  84. fi
  85.  
  86. #is there a usb drive/card reader, or Zip? (B:)
  87. BDRIVE=""
  88. if [ ! "$USBDRIVE" = "" ];then
  89.  BDRIVE="${USBDRIVE}${USBPARTNUM}"
  90.  LETTERB="b"
  91.  BINFO=" b: is a USB partition at $BDRIVE
  92. "
  93. else
  94.  #what about a zip drive?
  95.  if [ ! "$ZIPFND" = "" ];then
  96.   BDRIVE="${ZIPDRIVE}${ZIPPARTNUM}"
  97.   LETTERB="b"
  98.   BINFO=" b: is a Zip partition at $BDRIVE
  99. "
  100.  fi
  101. fi
  102.  
  103. #is there a zip drive? (D:)
  104. if [ ! "$USBDRIVE" = "" ];then #means usb drive has grabbed B:.
  105.  if [ ! "$ZIPFND" = "" ];then
  106.   DDRIVE="${ZIPDRIVE}${ZIPPARTNUM}"
  107.   LETTERD="d"
  108.   DINFO=" d: is a Zip partition at $DDRIVE
  109. "
  110.  fi
  111. fi
  112.  
  113. #need to write to /etc/mtools.conf and /etc/mtoolsfm.conf...
  114.  
  115. echo "#Configuration file for MTools. Generated by /usr/local/bin/mtoolsfmshell" > /etc/mtools.conf
  116. echo "# " >> /etc/mtools.conf
  117.  
  118. if [ ! "$ADRIVE" = "" ];then
  119.  echo "drive a: file=\"/dev/fd0\" exclusive" >> /etc/mtools.conf
  120. fi
  121. if [ ! "$BDRIVE" = "" ];then
  122.  echo "drive b: file=\"${BDRIVE}\"" >> /etc/mtools.conf
  123. fi
  124. if [ ! "$CDRIVE" = "" ];then
  125.  echo "drive c: file=\"${CDRIVE}\"" >> /etc/mtools.conf
  126. fi
  127. if [ ! "$DDRIVE" = "" ];then
  128.  echo "drive d: file=\"$DDRIVE\"" >> /etc/mtools.conf
  129. fi
  130.  
  131. echo "#Configuration for MToolsFM. Generated by /usr/local/bin/mtoolsfmshell" > /etc/mtoolsfm.conf
  132. echo "# " >> /etc/mtoolsfm.conf
  133. echo "DRIVES=\"${LETTERA}${LETTERB}${LETTERC}${LETTERD}\"" >> /etc/mtoolsfm.conf
  134. if [ "$BDRIVE" ];then
  135.  echo "LEFTDRIVE=\"b\"" >> /etc/mtoolsfm.conf
  136. else
  137.  if [ "$ADRIVE" ];then
  138.   echo "LEFTDRIVE=\"a\"" >> /etc/mtoolsfm.conf
  139.  else
  140.   echo "LEFTDRIVE=\"c\"" >> /etc/mtoolsfm.conf
  141.  fi
  142. fi
  143. echo "RIGHTDRIVE=\" \"" >> /etc/mtoolsfm.conf
  144.  
  145.  
  146. sync #important I think
  147. /usr/local/bin/MToolsFM &
  148. MTINFO="These are the drive letters used by MToolsFM:
  149. ${AINFO}${BINFO}${CINFO}${DINFO}
  150. MToolsFM does NOT need these to be mounted!"
  151. xmessage -timeout 120 -bg "#ff00ff" -title "MToolsFM information" -buttons "" "$MTINFO" &
  152.