You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.9 KiB

  1. #!/bin/sh
  2. # prepare parameters for ToI
  3. . /lib/dracut-lib.sh
  4. info "TuxOnIce premodule started"
  5. # first check if ToI support is available
  6. if [ ! -d /sys/power/tuxonice ]; then
  7. info "Kernel has no tuxonice support, aborting"
  8. return 0
  9. else
  10. info "Kernel has tuxonice support, continuing"
  11. fi
  12. if getarg noresume2; then
  13. warn "noresume2 was specified, aborting"
  14. return 0
  15. fi
  16. # prepare UserUI
  17. info "Setting up UserUI"
  18. UI="/sbin/tuxoniceui"
  19. UIOPTS=""
  20. if [ -e "/sys/class/graphics/fb0/state" -a -e "/etc/splash/tuxonice/" ]; then
  21. UIOPTS="$UIOPTS -f"
  22. fi
  23. SYSFS_TUI_UI=/sys/power/tuxonice/user_interface
  24. PROGRAM_PATH=${SYSFS_TUI_UI}/program
  25. ENABLED_PATH=${SYSFS_TUI_UI}/enabled
  26. if [ -e "$UI" ] && [ -e "$PROGRAM_PATH" ] && [ -e "$ENABLED_PATH" ]; then
  27. info "Using $UI with $UIOPTS"
  28. echo "$UI $UIOPTS" >$PROGRAM_PATH
  29. echo 1 >$ENABLED_PATH
  30. else
  31. if [ -e "$ENABLED_PATH" ]; then
  32. echo 0 >$ENABLED_PATH
  33. fi
  34. fi
  35. # install udev rule for resume parameter
  36. if resume=$(getarg resume=) && ! getarg noresume2; then
  37. resume="${resume#file:}"
  38. resume="${resume#swap:}"
  39. resume="${resume%:*}"
  40. else
  41. unset resume
  42. fi
  43. info "Installing udev rule for resume parameter"
  44. case "$resume" in
  45. LABEL=*) \
  46. resume="$(echo $resume | sed 's,/,\\x2f,g')"
  47. {
  48. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_LABEL}==\"${resume#LABEL=}\", " \
  49. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'resume'\"";
  50. } >> /etc/udev/rules.d/99-tuxonice.rules
  51. ;;
  52. UUID=*) \
  53. {
  54. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_UUID}==\"${resume#UUID=}\", " \
  55. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'resume'\"";
  56. } >> /etc/udev/rules.d/99-tuxonice.rules
  57. ;;
  58. PARTUUID=*) \
  59. {
  60. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_PART_ENTRY_UUID}==\"${resume#PARTUUID=}\", " \
  61. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'resume'\"";
  62. } >> /etc/udev/rules.d/99-tuxonice.rules
  63. ;;
  64. *) \
  65. {
  66. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", SYMLINK==\"${resume#/dev/}\", " \
  67. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'resume'\"";
  68. } >> /etc/udev/rules.d/99-tuxonice.rules
  69. {
  70. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", KERNEL==\"${resume#/dev/}\", " \
  71. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'resume'\"";
  72. } >> /etc/udev/rules.d/99-tuxonice.rules
  73. ;;
  74. esac
  75. # install udev rule for resuming
  76. info "Installing udev rule for ToI resume"
  77. {
  78. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"suspend|swsuspend|swsupend\", " \
  79. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'suspend'\"";
  80. } >> /etc/udev/rules.d/99-tuxonice.rules
  81. # install udev rule to add swapdevice as hibernation target
  82. info "Installing udev rule for ToI swap detection"
  83. {
  84. echo "SUBSYSTEM==\"block\", ACTION==\"add|change\", ENV{ID_FS_TYPE}==\"swap\", " \
  85. " RUN+=\"/sbin/tuxonice-resumecheck.sh '/dev/%k' 'swap'\"";
  86. } >> /etc/udev/rules.d/99-tuxonice.rules