]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
[PATCH 32/50] Created pre-mount hook directory
authorVictor Lowther <victor.lowther@gmail.com>
Fri, 13 Feb 2009 12:42:48 +0000 (04:42 -0800)
committerDave Jones <davej@redhat.com>
Mon, 16 Feb 2009 18:56:42 +0000 (13:56 -0500)
This is for tasks that should run after device discovery, but before
mounting the new rootfs.  Things like cryptoroot and resume from hibernate
should go here.

Hooks are sourced, not executed as separate scripts.

init
pre-mount/50cryptroot [new file with mode: 0644]
pre-mount/99resume [new file with mode: 0644]

diff --git a/init b/init
index b12743c88db503b68b065866eb028c06be148137..0b158dc26baba1e76018d03b0d0dfc511b304e8f 100755 (executable)
--- a/init
+++ b/init
@@ -14,9 +14,17 @@ emergency_shell()
 }
 
 getarg() {
+    local o;
     for o in $(< /proc/cmdline); do
        [[ $o == $1 ]] && { echo $o; break; }
     done
+    return 1
+}
+
+source_all() {
+    local f
+    [[ -d $1 ]] || return
+    for f in "$d"/*; do; . "$f"; done
 }
 
 echo "Starting initrd..."
@@ -67,12 +75,8 @@ esac
 tries=0
 echo "Waiting up to 30 seconds for $root to become available"
 udevadm settle --timeout=30
-[[ -f /cryptroot ]] && {
-    echo "Encrypted root detected."
-    cryptopts=$(< /cryptroot)
-    /sbin/cryptsetup luksOpen $cryptopts || emergency_shell
-    udevadm settle --timeout=30
-}
+source_all /pre-mount
+
 echo "Trying to mount rootfs $root"
 [[ -e $root ]] || emergency_shell
 ln -s "$root" /dev/root    
diff --git a/pre-mount/50cryptroot b/pre-mount/50cryptroot
new file mode 100644 (file)
index 0000000..39e6e6e
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+[[ -f /cryptroot ]] || return
+echo "Encrypted root detected."
+cryptopts=$(< /cryptroot)
+/sbin/cryptsetup luksOpen $cryptopts || emergency_shell
+udevadm settle --timeout=30
diff --git a/pre-mount/99resume b/pre-mount/99resume
new file mode 100644 (file)
index 0000000..7eacd38
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+resume=$(getarg 'resume=*') || return
+resume=${resume#resume=}
+[[ -b $resume ]] || return
+# parsing the output of ls is Bad, but until there is a better way...
+read x x x x maj min x < <(ls -lH "$resume")
+echo "${maj/,/}:$min"> /sys/power/resume