libreboot_usb_bugfix 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #! /bin/sh
  2. ################################################################################
  3. # Copyright (C) 2016 Namine Ritsu <ritsu73@ecantorix.moe> #
  4. # #
  5. # This program is free software: you can redistribute it and/or modify #
  6. # it under the terms of the GNU General Public License as published by #
  7. # the Free Software Foundation, either version 3 of the License, or #
  8. # (at your option) any later version. #
  9. # #
  10. # This program is distributed in the hope that it will be useful, #
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. # GNU General Public License for more details. #
  14. # #
  15. # You should have received a copy of the GNU General Public License #
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>. #
  17. # #
  18. ################################################################################
  19. ### BEGIN INIT INFO
  20. # Provides: libreboot_usb_bugfix
  21. # Required-Start: $remote_fs $syslog
  22. # Required-Stop: $remote_fs $syslog
  23. # Default-Start: 2 3 4 5
  24. # Default-Stop:
  25. # Short-Description: Disable USB wakeup on libreboot machines
  26. ### END INIT INFO
  27. case "$1" in
  28. start)
  29. EHC1=$(cat /proc/acpi/wakeup | grep EHC1 | grep enabled | wc -l)
  30. EHC2=$(cat /proc/acpi/wakeup | grep EHC2 | grep enabled | wc -l)
  31. if [ "$EHC1" -gt 0 ]
  32. then
  33. echo EHC1 > /proc/acpi/wakeup
  34. fi
  35. if [ "$EHC2" -gt 0 ]
  36. then
  37. echo EHC2 > /proc/acpi/wakeup
  38. fi
  39. ;;
  40. status)
  41. cat /proc/acpi/wakeup | grep EHC
  42. ;;
  43. *)
  44. echo "Usage: /etc/init.d/libreboot_usb_bugfix {start|status}"
  45. exit 1
  46. esac
  47. exit 0