From 8dcf20f4b51e5dd295a64fc49b33c073e0fe6810 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Fri, 13 Sep 2013 15:42:05 +0200 Subject: [PATCH] initrd.scripts: move swsusp code to 00-suspend.sh --- defaults/initrd.d/00-suspend.sh | 29 +++++++++++++++++++++++++++++ defaults/initrd.scripts | 29 +---------------------------- 2 files changed, 30 insertions(+), 28 deletions(-) create mode 100755 defaults/initrd.d/00-suspend.sh diff --git a/defaults/initrd.d/00-suspend.sh b/defaults/initrd.d/00-suspend.sh new file mode 100755 index 0000000..60dbbd8 --- /dev/null +++ b/defaults/initrd.d/00-suspend.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +resume_init() { + if [ -z "${REAL_RESUME}" ]; then + return 0 + fi + if [ "${NORESUME}" = "1" ]; then + return 0 + fi + + local resume_dev=$(find_real_device "${REAL_RESUME}") + if [ -n "${resume_dev}" ]; then + REAL_RESUME="${resume_dev}" + good_msg "Detected real_resume=${resume_dev}" + else + bad_msg "Cannot resolve real_resume=${REAL_RESUME}" + bad_msg "Something bad may happen, crossing fingers" + fi + + swsusp_resume +} + +swsusp_resume() { + # determine swap resume partition + local device=$(ls -lL "${REAL_RESUME}" | sed 's/\ */ /g' | \ + cut -d \ -f 5-6 | sed 's/,\ */:/') + [ -f /sys/power/resume -a -n "${device}" ] && \ + echo "${device}" > /sys/power/resume +} diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index e425b9b..53878e6 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -11,6 +11,7 @@ . /etc/initrd.d/00-nfs.sh . /etc/initrd.d/00-keymaps.sh . /etc/initrd.d/00-crypt.sh +. /etc/initrd.d/00-suspend.sh real_root_init() { @@ -84,34 +85,6 @@ start_iscsi() { fi } -resume_init() { - if [ -z "${REAL_RESUME}" ]; then - return 0 - fi - if [ "${NORESUME}" = "1" ]; then - return 0 - fi - - local resume_dev=$(find_real_device "${REAL_RESUME}") - if [ -n "${resume_dev}" ]; then - REAL_RESUME="${resume_dev}" - good_msg "Detected real_resume=${resume_dev}" - else - bad_msg "Cannot resolve real_resume=${REAL_RESUME}" - bad_msg "Something bad may happen, crossing fingers" - fi - - swsusp_resume -} - -swsusp_resume() { - # determine swap resume partition - local device=$(ls -lL "${REAL_RESUME}" | sed 's/\ */ /g' | \ - cut -d \ -f 5-6 | sed 's/,\ */:/') - [ -f /sys/power/resume -a -n "${device}" ] && \ - echo "${device}" > /sys/power/resume -} - getdvhoff() { echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512)) }