[PATCH 32/50] Created pre-mount hook directory

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.
master
Victor Lowther 2009-02-13 04:42:48 -08:00 committed by Dave Jones
parent b32f55156d
commit cd20f1f6eb
3 changed files with 23 additions and 6 deletions

16
init
View File

@ -14,9 +14,17 @@ emergency_shell()
} }


getarg() { getarg() {
local o;
for o in $(< /proc/cmdline); do for o in $(< /proc/cmdline); do
[[ $o == $1 ]] && { echo $o; break; } [[ $o == $1 ]] && { echo $o; break; }
done done
return 1
}

source_all() {
local f
[[ -d $1 ]] || return
for f in "$d"/*; do; . "$f"; done
} }


echo "Starting initrd..." echo "Starting initrd..."
@ -67,12 +75,8 @@ esac
tries=0 tries=0
echo "Waiting up to 30 seconds for $root to become available" echo "Waiting up to 30 seconds for $root to become available"
udevadm settle --timeout=30 udevadm settle --timeout=30
[[ -f /cryptroot ]] && { source_all /pre-mount
echo "Encrypted root detected."
cryptopts=$(< /cryptroot)
/sbin/cryptsetup luksOpen $cryptopts || emergency_shell
udevadm settle --timeout=30
}
echo "Trying to mount rootfs $root" echo "Trying to mount rootfs $root"
[[ -e $root ]] || emergency_shell [[ -e $root ]] || emergency_shell
ln -s "$root" /dev/root ln -s "$root" /dev/root

6
pre-mount/50cryptroot Normal file
View File

@ -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

7
pre-mount/99resume Normal file
View File

@ -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