Message info
 
To:arch-projects@archlinux.org From:Dave Reisner Subject:[arch-projects] [mkinitcpio][PATCH 14/19] init: add support for late running hooks Date:Sun, 13 May 2012 13:57:17 -0400
 

This adds support for a second round of hooks during early userspace.
Users can define a 'run_latehook' in their hook script similar to the
declaration of 'run_hook' which continues to run at the same point in
execution. 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 other partitions
- moving config to the real root (mostly for liveCDs)
- shutting down previously started daemons

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
init | 2 ++
init_functions | 11 +++++++++++
2 files changed, 13 insertions(+)

diff --git a/init b/init
index a8915fb..275ac68 100644
--- a/init
+++ b/init
@@ -71,6 +71,8 @@ elif [ ! -x "/new_root${init}" ]; then
launch_interactive_shell --exec
fi

+run_hookfunctions 'run_latehook' 'late hook' $(reverse_list "$HOOKS")
+
# mount /usr if it exists
realtab=/new_root/etc/fstab
if [ -f "$realtab" ]; then
diff --git a/init_functions b/init_functions
index 1bebf45..0ba4cd5 100644
--- a/init_functions
+++ b/init_functions
@@ -7,6 +7,17 @@ err () {
echo "ERROR: $@"
}

+reverse_list() {
+ local x rev=$1
+
+ shift
+ for x; do
+ rev="$x $rev"
+ done
+
+ printf '%s' "$rev"
+}
+
poll_device() {
local device=$1 seconds=${2//[!0-9]}

--
1.7.10.2