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.
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 *~
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
#!/bin/bash
inst cryptsetup
-inst_rules "$dsrc/rules.d/63-luks.rules"
\ No newline at end of file
+inst_rules "$dsrc/rules.d/63-luks.rules"
+inst_hook pre-mount 50 "$dsrc/hooks/cryptroot"
\ No newline at end of file
# 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"