Support live-{top,premount,bottom} hooks
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Wed, 13 Dec 2017 17:40:37 +0000 (18:40 +0100)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 15 Mar 2018 18:53:54 +0000 (19:53 +0100)
initramfs-tools support hooks for top, premount, bottom when booting
with boot=local or boot=nfs. Add similar support to live-boot when
booting with boot=live.

Closes: #884355
Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
backend/initramfs-tools/live.script

index ff2915a..5bec741 100755 (executable)
@@ -1,13 +1,59 @@
-#!/bin/sh
-
-#set -e
+# Live system filesystem mounting                      -*- shell-script -*-
 
 . /bin/live-boot
 
 
 . /bin/live-boot
 
-. /scripts/functions
+live_top()
+{
+       if [ "${live_top_used}" != "yes" ]; then
+               [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-top"
+               run_scripts /scripts/live-top
+               [ "$quiet" != "y" ] && log_end_msg
+       fi
+       live_top_used=yes
+}
+
+live_premount()
+{
+       if [ "${live_premount_used}" != "yes" ]; then
+               [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-premount"
+               run_scripts /scripts/live-premount
+               [ "$quiet" != "y" ] && log_end_msg
+       fi
+       live_premount_used=yes
+}
+
+live_bottom()
+{
+       if [ "${live_premount_used}" = "yes" ] || [ "${live_top_used}" = "yes" ]; then
+               [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-bottom"
+               run_scripts /scripts/live-bottom
+               [ "$quiet" != "y" ] && log_end_msg
+       fi
+       live_premount_used=no
+       live_top_used=no
+}
+
 
 
-mountroot ()
+mountroot()
 {
        # initramfs-tools entry point for live-boot is mountroot(); function
        Live
 }
 {
        # initramfs-tools entry point for live-boot is mountroot(); function
        Live
 }
+
+mount_top()
+{
+       # Note, also called directly in case it's overridden.
+       live_top
+}
+
+mount_premount()
+{
+       # Note, also called directly in case it's overridden.
+       live_premount
+}
+
+mount_bottom()
+{
+       # Note, also called directly in case it's overridden.
+       live_bottom
+}