daily pastebin goal
64%
SHARE
TWEET

initrd/sbin/wait4usb (s243a's tahrpup6.0.6 mods)

s243a Jan 28th, 2018 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh #Delta file: https://pastebin.com/9d3DANGq related delta (/initrd/init): https://pastebin.com/T5QjauWm
  2. #this is called from 'init', runs as parallel process.
  3. #110710 rewritten for kernel with hid and usb drivers builtin, and without my usb-storage patch.
  4. #110713 have put my usb-storage patch back in to kernel (2.6.39-3).
  5. #120330 mmc drives may be slow to become ready, so add them in here.
  6.  
  7. #sleep 1
  8. USBSTORAGES=0 ; CNTUSB=0
  9. WAITDEV="${WAITDEV:-3}"
  10. while [ $USBSTORAGES -eq 0 ];do
  11.  sleep 1
  12.  echo -n "." > /dev/console
  13.  CNTUSB=$(($CNTUSB+1))
  14.  [ $CNTUSB -gt 5 ] && break
  15.  #v412 bug, ubuntu kernel, got duplicate 'device found at 2', need 'sort -u'...
  16.  USBSTORAGES=`/bin/dmesg | grep "usb-storage: device found at" | sort -u | wc -l`
  17.  [ $USBSTORAGES -eq 0 ] && break
  18.  AVAILABLEUSBSTORAGES=`/bin/dmesg | grep "usb-storage: device scan complete" | wc -l`
  19.  [ $USBSTORAGES -ne $AVAILABLEUSBSTORAGES ] && USBSTORAGES=0
  20. done
  21.  
  22. #i want this to work with kernel that does not have my usb-storage patch, feedback is that 3 secs is enough...
  23. while [ $CNTUSB -lt $WAITDEV ];do
  24.  sleep 1
  25.  CNTUSB=$(($CNTUSB+1))
  26.  echo -en "\\033[1;33m.\\033[0;39m" >/dev/console #yellow dot
  27. done
  28.  
  29. #wait for usb partitions to become available...
  30. #entries in /sys/block show up, but ex /sys/block/sda/sda1 takes a bit longer...
  31. #note, if usb card-reader plugged in but no cards inserted, this will timeout...
  32. #note, will also timeout if usb optical drive (sr), but ok, they need extra time...
  33. ALLUSBDRVS="`find /sys/block -maxdepth 1 -name 'sd*' -o -name 'sr*' | xargs -n 1 readlink 2>/dev/null | grep '/usb[0-9]' | rev | cut -f 1 -d '/' | rev | tr '\n' ' '`"
  34. [ "$ALLUSBDRVS" = " " ] && ALLUSBDRVS=""
  35. for ONEDRV in $ALLUSBDRVS
  36. do
  37.  while [ ! -e /sys/block/${ONEDRV}/${ONEDRV}1 ];do
  38.   sleep 1
  39.   echo -en "\\033[1;31m.\\033[0;39m" >/dev/console #red dot
  40.   CNTUSB=$(($CNTUSB+1))
  41.   [ $CNTUSB -gt 6 ] && break
  42.  done
  43.  #force update of /proc/partitions...
  44.  dd if=/dev/${ONEDRV} of=/dev/null bs=512 count=1 >/dev/null 2>&1
  45. done
  46.  
  47. #120330 probe for mmc drives...
  48. MMCDRVS=""
  49. if [ "`grep '^mmc' /tmp/ALLDRVS0`" = "" ];then  #find out if already available.
  50.  [ "`lsmod | grep '^mmc'`" != "" ] && MMCDRVS="`find /sys/block -maxdepth 1 -name 'mmc*' | tr '\n' ' '`"
  51.  [ "$MMCDRVS" = " " ] && MMCDRVS=""
  52. fi
  53.  
  54. echo -n "$ALLUSBDRVS" > /tmp/flag-usb-ready
  55. [ "$MMCDRVS" ] && echo -n " ${MMCDRVS}" >> /tmp/flag-usb-ready
  56.  
  57. ###end###
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top