Want more features on Pastebin? Sign Up, it's FREE!

compat-wireless

By: swiftgeek on May 4th, 2012  |  syntax: Bash  |  size: 2.03 KB  |  views: 197  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. # Author: Swift Geek ‹ swiftgeek (at) gmail (dot) com › 😸
  3.  
  4. # Includes
  5. . /etc/rc.conf
  6. . /etc/rc.d/functions
  7.  
  8. # Make package outdated ;)
  9.  
  10. function MakePackageOutdated
  11. {
  12.   ___COMPAT_VERSION="`echo /var/lib/pacman/local/compat-wireless-patched*/ | awk -F'[/,-]' '{print $9 "-" $10}'`"
  13.  
  14.   sed -i "s/$___COMPAT_VERSION/0.1-1/" /var/lib/pacman/local/compat-wireless-patched-$___COMPAT_VERSION/desc
  15.   [ "$?" != "0" ] && return 1
  16.   mv /var/lib/pacman/local/compat-wireless-patched-$___COMPAT_VERSION /var/lib/pacman/local/compat-wireless-patched-0.1-1
  17.   [ "$?" != "0" ] && return 1
  18. #  echo "Package is now outdated"
  19.   return 0
  20. }
  21.  
  22. # Check if a currently running kernel is the official one and upgraded (after upgrade it is NOT) — otherwise skip (use stat -L)
  23. # It does a false positive when package is reinstalled with the same build
  24.  
  25. function IsKernelCurrent
  26. {
  27.   if [ -e "/var/lib/pacman/sync/core.db" ]; then
  28.     ___KERNEL_VERSION="`uname -r | awk -F"-A" '{print $1}'`"
  29.     if [ -d "/var/lib/pacman/local/linux-$___KERNEL_VERSION" ]; then
  30. #      echo "Kernel is current"
  31.       return 0
  32.     else
  33.       return 69
  34.     fi
  35.   else
  36.     return 96
  37.   fi
  38. }
  39.  
  40. # Main part of daemon – no reusable code down here
  41.  
  42. case "$1" in
  43.   start)
  44.     IsKernelCurrent
  45.     case "$?" in
  46.       "0")
  47.         if [ "`modinfo -n mac80211 | awk -F'/' '{print $5}'`" = "extramodules" ]; then
  48.           stat_busy "Compat-wireless is up and running"
  49.           stat_done
  50.         else
  51.           stat_busy "Compat-wireless needs recompiling"
  52.           MakePackageOutdated
  53.           if [ "$?" = "0" ]; then
  54.             stat_done
  55.           else
  56.             stat_fail
  57.           fi
  58.         fi
  59.         ;;
  60.       "96")
  61.         stat_busy "Compat-wireless: pacman-cage or /var partition not mounted"
  62.         stat_fail
  63.         ;;
  64.       "69")
  65.         stat_busy "Compat-wireless: reboot needed — kernel is outdated"
  66.         stat_fail
  67.         ;;
  68.     esac
  69.     ;;
  70.   restart)
  71.     $0 start
  72.     ;;
  73.   *)
  74.     echo "usage: $0 {start}"
  75.     ;;
  76. esac
clone this paste RAW Paste Data