Browse Source

[PATCH 49/50] Modify hook loading to make it slightly easier to script.

Modules are now responsible for loading their hooks into the initrd.

This should be all the structure we need to make it easy for things
to integrate with dracut -- now to document and test it all.
master
Victor Lowther 16 years ago committed by Dave Jones
parent
commit
53f954561a
  1. 8
      Makefile
  2. 16
      dracut-functions
  3. 0
      hooks/cryptroot
  4. 0
      hooks/resume
  5. 0
      hooks/selinux-loadpolicy
  6. 3
      modules/90crypt
  7. 7
      modules/99base

8
Makefile

@ -4,16 +4,16 @@ all: @@ -4,16 +4,16 @@ all:
install:
mkdir -p $(DESTDIR)/usr/libexec/dracut
mkdir -p $(DESTDIR)/sbin
mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-mount
mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-udev
mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-pivot
mkdir -p $(DESTDIR)/usr/libexec/dracut/hooks
mkdir -p $(DESTDIR)/usr/libexec/dracut/modules
install -m 0755 dracut $(DESTDIR)/sbin/dracut
install -m 0755 init $(DESTDIR)/usr/libexec/dracut/init
install -m 0755 switch_root $(DESTDIR)/usr/libexec/dracut/switch_root
install -m 0755 dracut-functions $(DESTDIR)/usr/libexec/dracut/functions
mkdir $(DESTDIR)/usr/libexec/dracut/rules.d
for rule in rules.d/*.rules ; do install -m 0644 $$rule $(DESTDIR)/usr/libexec/dracut ; done
for hooks in pre-*/* ; do install -m 0755 $$hook $(DESTDIR/usr/libexec/dracut ; done
for hooks in hooks/* ; do install -m 0755 $$hook $(DESTDIR)/usr/libexec/dracut ; done
for module in modules/*; do install -m 0755 $$module $(DESTDIR)/usr/libexec/dracut ; done
clean:
rm -f *~


16
dracut-functions

@ -145,6 +145,22 @@ inst() { @@ -145,6 +145,22 @@ inst() {
return 1
}

# install function specialized for hooks
# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
# All hooks should be POSIX/SuS compliant, they will be sourced by init.
inst_hook() {
[[ -f $3 ]] || {
echo "Cannot install a hook ($3) that does not exist." >&2
echo "Aborting initrd creation." >&2
exit 1
}
strstr "$hookdirs" "$1" || {
echo "No such hook type $1. Aborting initrd creation." >&2
exit 1
}
inst_simple "$3" "/${1}/${2}${3##*/}"
}

dracut_install() {
while (($# > 0)); do
inst "$1" && shift

0
pre-mount/50cryptroot → hooks/cryptroot

0
pre-mount/99resume → hooks/resume

0
pre-pivot/50selinux-loadpolicy → hooks/selinux-loadpolicy

3
modules/90crypt

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#!/bin/bash
inst cryptsetup
inst_rules "$dsrc/rules.d/63-luks.rules"
inst_rules "$dsrc/rules.d/63-luks.rules"
inst_hook pre-mount 50 "$dsrc/hooks/cryptroot"

7
modules/99base

@ -4,9 +4,6 @@ dracut_install mount mknod mkdir modprobe pidof sleep chroot echo sed sh ls @@ -4,9 +4,6 @@ dracut_install mount mknod mkdir modprobe pidof sleep chroot echo sed sh ls
# install our scripts and hooks
inst "$initfile" "/init"
inst "$switchroot" "/sbin/switch_root"
for hookdir in $hookdirs; do
for hook in "$dsrc/$hookdir"/*; do
[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
done
done
inst_hook pre-pivot 50 "$dsrc/hooks/selinux-loadpolicy"
inst_hook pre-mount 99 "$dsrc/hooks/resume"


Loading…
Cancel
Save