[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Generate /etc/initramfs-tools/conf.d/resume during install



Hello Folks,

 I've created a live-installer hook to generate the resume file (/etc/initramfs-tools/conf.d/resume) which is needed for hibernate to work. It takes advantage of code in base-installer to help do this so behavior is guaranteed to be near identical to that which would occur during a normal d-i install.

Cheers,

--
Cody A.W. Somerville
Software Systems Release Engineer
Foundations Team
Custom Engineering Solutions Group
Canonical OEM Services
Phone: +1-781-850-2087
Cell: +1-506-471-8402
Email: cody.somerville@canonical.com
diff -Nur a/live-installer.d/initramfs-tools b/live-installer.d/initramfs-tools
--- a/live-installer.d/initramfs-tools	1969-12-31 20:00:00.000000000 -0400
+++ b/live-installer.d/initramfs-tools	2009-07-28 16:33:11.000000000 -0300
@@ -0,0 +1,30 @@
+#!/bin/sh -e
+
+# Detect resume partition and write it to configuration file.
+
+. /usr/lib/base-installer/library.sh
+
+resumeconf=$IT_CONFDIR/resume
+
+resume_devfs="$(get_resume_partition)" || resume_devfs=
+if [ "$resume_devfs" ] && [ -e "$resume_devfs" ]; then
+	resume="$(mapdevfs "$resume_devfs")" || resume=
+else
+	resume=
+fi
+
+if [ "$resume" ]; then
+	resume_uuid="$(block-attr --uuid "$resume" || true)"
+	if [ "$resume_uuid" ]; then
+		resume="UUID=$resume_uuid"
+	fi
+fi
+
+if [ -n "$resumeconf" ] && [ "$resume" ]; then
+	if [ -f $resumeconf ] ; then
+		sed -e "s@^#* *RESUME=.*@RESUME=$resume@" < $resumeconf > $resumeconf.new &&
+			mv $resumeconf.new $resumeconf
+	else
+		echo "RESUME=$resume" >> $resumeconf
+	fi
+fi

Reply to: