Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # BEGIN configuration
  4. RUNLEVEL_AC="default"
  5. RUNLEVEL_BATTERY="battery"
  6. # END configuration
  7.  
  8.  
  9. if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
  10. then
  11. logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
  12. exit 1
  13. fi
  14.  
  15. if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
  16. then
  17. logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
  18. exit 1
  19. fi
  20.  
  21. if on_ac_power
  22. then
  23. if [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
  24. then
  25. logger "Switching to ${RUNLEVEL_AC} runlevel"
  26. /sbin/rc ${RUNLEVEL_AC}
  27. fi
  28. elif [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
  29. then
  30. logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
  31. /sbin/rc ${RUNLEVEL_BATTERY}
  32. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement