Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # invoke insmod with all arguments we got
  4. # and use a pathname, as insmod doesn't look in . by default
  5.  
  6. TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net/ethernet -name realtek -type d)
  7. if [ "$TARGET_PATH" = "" ]; then
  8. TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net -name realtek -type d)
  9. fi
  10. if [ "$TARGET_PATH" = "" ]; then
  11. TARGET_PATH=/lib/modules/$(uname -r)/kernel/drivers/net
  12. fi
  13. echo
  14. echo "Check old driver and unload it."
  15. check=`lsmod | grep r8169`
  16. if [ "$check" != "" ]; then
  17. echo "rmmod r8169"
  18. /sbin/rmmod r8169
  19. fi
  20.  
  21. check=`lsmod | grep r8168`
  22. if [ "$check" != "" ]; then
  23. echo "rmmod r8168"
  24. /sbin/rmmod r8168
  25. fi
  26.  
  27. echo "Build the module and install"
  28. echo "-------------------------------" >> log.txt
  29. date 1>>log.txt
  30. make $@ all 1>>log.txt || exit 1
  31. module=`ls src/*.ko`
  32. module=${module#src/}
  33. module=${module%.ko}
  34.  
  35. if [ "$module" = "" ]; then
  36. echo "No driver exists!!!"
  37. exit 1
  38. elif [ "$module" != "r8169" ]; then
  39. if test -e $TARGET_PATH/r8169.ko ; then
  40. echo "Backup r8169.ko"
  41. if test -e $TARGET_PATH/r8169.bak ; then
  42. i=0
  43. while test -e $TARGET_PATH/r8169.bak$i
  44. do
  45. i=$(($i+1))
  46. done
  47. echo "rename r8169.ko to r8169.bak$i"
  48. mv $TARGET_PATH/r8169.ko $TARGET_PATH/r8169.bak$i
  49. else
  50. echo "rename r8169.ko to r8169.bak"
  51. mv $TARGET_PATH/r8169.ko $TARGET_PATH/r8169.bak
  52. fi
  53. fi
  54. fi
  55.  
  56. echo "DEPMOD $(uname -r)"
  57. depmod `uname -r`
  58. echo "load module $module"
  59. modprobe $module
  60.  
  61. is_update_initramfs=n
  62. distrib_list="ubuntu debian"
  63.  
  64. if [ -r /etc/debian_version ]; then
  65. is_update_initramfs=y
  66. elif [ -r /etc/lsb-release ]; then
  67. for distrib in $distrib_list
  68. do
  69. /bin/grep -i "$distrib" /etc/lsb-release 2>&1 /dev/null && \
  70. is_update_initramfs=y && break
  71. done
  72. fi
  73.  
  74. if [ "$is_update_initramfs" = "y" ]; then
  75. if which update-initramfs >/dev/null ; then
  76. echo "Updating initramfs. Please wait."
  77. update-initramfs -u -k $(uname -r)
  78. else
  79. echo "update-initramfs: command not found"
  80. exit 1
  81. fi
  82. fi
  83.  
  84. echo "Completed."
  85. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement