Advertisement
theroot

mrebuild.sh

Feb 9th, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1.  
  2. #!/bin/bash
  3.  
  4. # this rebuilds all modules built against a kernel - used after a kernel update.
  5.  
  6. tmpfile="/tmp/rebuild.list"
  7. mr_packages=""
  8. tm_cmd="emerge -v"
  9. mr_modules=""
  10. mr_command=""
  11.  
  12. . /etc/conf.d/mrebuild.conf
  13.  
  14. function prep() {
  15.  
  16.         >${tmpfile}
  17.  
  18. }
  19.  
  20. function populate_list() {
  21.  
  22.         module-rebuild populate
  23.         module-rebuild list |awk '{if (NR!=1) {print}}'|tr -d " " |awk '{print $1}' >>${tmpfile} |tee
  24.         qlist -IC x11-drivers/ >>${tmpfile}
  25.         echo "${mr_packages}" >>${tmpfile}
  26.  
  27. }
  28.  
  29. function rebuild_list() {
  30.  
  31.         ${tm_cmd} ${tm_opts} `cat ${tmpfile}`
  32.  
  33. }
  34.  
  35. function reload_modules() {
  36.  
  37.         rmmod ${mr_modules}
  38.         ${mr_command}
  39.         modprobe ${mr_modules}
  40.         /etc/init.d/modules restart
  41.  
  42. }
  43.  
  44. function cleanup() {
  45.  
  46.         rm ${tmpfile}
  47.         env-update
  48.         source /etc/profile
  49.         echo -e "\nMODULES REBUILT AND RELOADED...\n"
  50.  
  51. }
  52.  
  53. case ${1} in
  54.         --go)
  55.                 prep
  56.                 populate_list
  57.                 rebuild_list
  58.                 reload_modules
  59.                 cleanup
  60.         ;;
  61. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement