Advertisement
Guest User

hotplug-usb.sh

a guest
Jun 21st, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #set -x
  4. set +v
  5. PREFIX_PATH="/var"
  6. STATUS_FILE=$PREFIX_PATH"/etc/3g-status"
  7. DRIVER_STATUS_FILE=$PREFIX_PATH"/etc/driver-status"
  8. DEBUG_FILE="/tmp/3g-hotplug.debug"
  9. ADAPTER_FILE=$PREFIX_PATH"/etc/adapter"
  10. LOCK="/tmp/hotplug-usb.lock"
  11. WIMAX_LOCK="/tmp/hotplug-wimax.lock"
  12. HOTPLUGINFO_FILE="/tmp/hotplug-add-remove.out"
  13.  
  14. DISABLE_HOTPLUG="/tmp/disable-hotplug"
  15. CELLD_READY_FILE="/tmp/celld_ready"
  16. USB_HOTPLUG_EVENT="/tmp/hotplug-usb_event"
  17.  
  18. DELAY_DRIVER=3
  19.  
  20. if [ -f "$DISABLE_HOTPLUG" ]; then
  21. echo `date` " hotplug-usb: hotplug disabled, exit" >> "$DEBUG_FILE"
  22. exit
  23. fi
  24.  
  25. if [ ! -f "$CELLD_READY_FILE" ]; then
  26. echo "usb hotplug event" > "$USB_HOTPLUG_EVENT"
  27. echo `date` " hotplug-usb: celld is not ready, exit" >> "$DEBUG_FILE"
  28. exit
  29. fi
  30.  
  31. rm -f $USB_HOTPLUG_EVENT
  32.  
  33. echo "==================================================" >> "$DEBUG_FILE"
  34.  
  35. mount -t usbfs usbfs /proc/bus/usb/
  36. sleep $DELAY_DRIVER
  37.  
  38. echo $ACTION | grep -q add
  39. if [ $? -eq 0 ] || [ "$1" == "add" ]; then
  40. echo `date` " hotplug-usb: Add " >> "$DEBUG_FILE"
  41.  
  42. if [ -f "$LOCK" ]; then
  43. echo `date` " hotplug-usb: Add has be lock, exit " >> "$DEBUG_FILE"
  44. exit
  45. fi
  46. echo `date` "" > "$LOCK"
  47. echo `date` " hotplug-usb: $$ hotplug.lock" >> "$DEBUG_FILE"
  48.  
  49. /sbin/3g.sh
  50.  
  51. rm -rf $LOCK
  52.  
  53. echo `date` " hotplug-usb: Add done " >> "$DEBUG_FILE"
  54. echo "" >> "$DEBUG_FILE"
  55. echo "------------------------------------------------" >> "$DEBUG_FILE"
  56. fi
  57.  
  58. echo $ACTION | grep -q remove
  59. if [ $? -eq 0 ] || [ "$1" == "remove" ]; then
  60. echo `date` " hotplug-usb: Remove " >> "$DEBUG_FILE"
  61.  
  62. # release the lock
  63.  
  64. rm $STATUS_FILE
  65. rm $DRIVER_STATUS_FILE
  66. rm $ADAPTER_FILE
  67.  
  68. rm -f $USB_HOTPLUG_EVENT
  69. rm -f /tmp/ms-configList
  70. rm -f /tmp/usb-get-ids.out
  71. rm -f /tmp/sys-bus-usb-devices
  72. rm -f /tmp/usb-find-devices
  73.  
  74. sleep $DELAY_DRIVER
  75.  
  76. rmmod option
  77. rmmod sierra
  78. rmmod usbserial
  79. rmmod lg-vl600
  80. rmmod cdc-acm
  81. rmmod hso
  82.  
  83. echo `date` " hotplug-usb: $$ release hotplug.lock" >> $DEBUG_FILE
  84. rm -rf $LOCK
  85.  
  86. echo `date` " hotplug-usb: Remove done " >> "$DEBUG_FILE"
  87. echo "" >> "$DEBUG_FILE"
  88. echo "------------------------------------------------" >> "$DEBUG_FILE"
  89.  
  90. exit
  91. fi
  92.  
  93. echo `date` " hotplug-usb: DONE " >> "$DEBUG_FILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement