From d858992503af95549961d982b98a727a2ede937e Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 11 May 2012 20:45:12 -0400 Subject: 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 --- init | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'init') diff --git a/init b/init index 3c852d9..44c10b0 100644 --- a/init +++ b/init @@ -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 -- cgit v1.2.3-24-g4f1b