diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-05-12 02:45:12 +0200 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-05-18 15:39:04 +0200 |
commit | d858992503af95549961d982b98a727a2ede937e (patch) | |
tree | da0694fbf5a268aa853511b001feea872f90381f | |
parent | 0ccb5f6e037bcbb0817cdb76274a37624c28cb5a (diff) | |
download | mkinitcpio-d858992503af95549961d982b98a727a2ede937e.tar.gz mkinitcpio-d858992503af95549961d982b98a727a2ede937e.tar.xz |
init: add support for early, late and cleanup hooks
This adds support for three more rounds of hooks during early userspace.
Users can define a 'run_latehook' in their hook script similar to the
declaration of 'run_hook' (which continue to run at the same point in
execution). These are run in the same order as the original "early"
hooks shortly after root is mounted.
Additionally, 'run_cleanup' hook can be defined which will run right
after the late hooks. These scripts are executed after mounting root in
reverse order of how they're clared in mkinitcpio'c config.
These late running hooks should take care of things such as:
- mounting /usr (possibly encrypted)
- moving config to the real root (mostly for liveCDs)
- shutting down previously started daemons (e.g. udev or dropbear)
Finally, we add run_earlyhook which is run as soon as possible. There
will likely be only a few subscribers to this, but udev will certainly
be one of them, as it needs to be started as early as possible when
present, to avoid problems with firmware loading.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r-- | init | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -26,10 +26,11 @@ for d in ${disablehooks//,/ }; do [ -e "/hooks/$d" ] && chmod 644 "/hooks/$d" done -[ -n "${earlymodules//[[:space:]]}" ] && modprobe -qab ${earlymodules//,/ } - . /config +run_hookfunctions 'run_earlyhook' 'early hook' $EARLYHOOKS + +[ -n "${earlymodules//[[:space:]]}" ] && modprobe -qab ${earlymodules//,/ } [ -n "${MODULES//[[:space:]]}" ] && modprobe -qab $MODULES # If rootdelay is empty or not a non-negative integer, set it to 10 @@ -71,6 +72,10 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi +run_hookfunctions 'run_latehook' 'late hook' $LATEHOOKS + +run_hookfunctions 'run_cleanuphook' 'cleanup hook' $CLEANUPHOOKS + # mount /usr if it exists realtab=/new_root/etc/fstab if [ -f "$realtab" ]; then |