powertop.trisquel7 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env bash
  2. # powertop.trisquel7: automatically sets up powertop --auto-tune on startup in trisquel 7
  3. #
  4. # Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. [ "x${DEBUG+set}" = 'xset' ] && set -v
  20. set -u -e
  21. if [ $EUID -ne 0 ]; then
  22. printf "This script must be run as root\n"
  23. exit 1
  24. fi
  25. # For Trisquel 7 users.
  26. apt-get -y install powertop
  27. # Remove startup symlink if it exists
  28. update-rc.d powertop remove
  29. # Remove previous file if it exists
  30. rm -Rf "/etc/init.d/powertop"
  31. # write the correct commands there:
  32. printf "#!/bin/sh\n" > "/etc/init.d/powertop"
  33. printf "/usr/sbin/powertop --auto-tune\n" >> "/etc/init.d/powertop"
  34. # make it executable:
  35. chmod +x "/etc/init.d/powertop"
  36. # Add the service to make it run automatically at boot time:
  37. update-rc.d powertop defaults
  38. # Run powertop now and tell the user
  39. powertop --auto-tune
  40. printf "Done. Run 'powertop --auto-tune' now. This will also run automatically at boot time. Run it again at any time, if needed. This has also been done for you just now.\n"