Since commit bb5d30ab2af5720775c63179afdec3ad9efd510d, we don't require any external programs like grep to parse the command line. We only use bash intrinsics. Therefore we can do it early (but after /proc is mounted). This allows verbose mode to enable set -x early on, so we can trace most things that the init script does. --- appliance/init | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/appliance/init b/appliance/init index 04afbd6..c4cf964 100755 --- a/appliance/init +++ b/appliance/init @@ -33,9 +33,29 @@ done mkdir -p /sysroot +# Mount /proc. if [ ! -d /proc ]; then rm -f /proc; fi mkdir -p /proc mount -t proc /proc /proc + +# Parse the kernel command line early (must be after /proc is mounted). +cmdline=$(</proc/cmdline) + +if [[ $cmdline == *guestfs_verbose=1* ]]; then + guestfs_verbose=1 + set -x +fi +if [[ $cmdline == *guestfs_network=1* ]]; then + guestfs_network=1 +fi +if [[ $cmdline == *guestfs_rescue=1* ]]; then + guestfs_rescue=1 +fi +if [[ $cmdline == *guestfs_noreboot=1* ]]; then + guestfs_noreboot=1 +fi + +# Mount the other special filesystems. if [ ! -d /sys ]; then rm -f /sys; fi mkdir -p /sys mount -t sysfs /sys /sys @@ -75,8 +95,6 @@ $UDEVD --daemon #--debug udevadm trigger udevadm settle --timeout=600 -cmdline=$(</proc/cmdline) - if [[ $cmdline == *selinux=1* ]]; then mount -t selinuxfs none /sys/fs/selinux fi @@ -92,22 +110,6 @@ shopt -u nullglob # Update the system clock. hwclock -u -s -# Parse the kernel command line. -if [[ $cmdline == *guestfs_verbose=1* ]]; then - guestfs_verbose=1 - set -x -fi -if [[ $cmdline == *guestfs_network=1* ]]; then - guestfs_network=1 -fi -if [[ $cmdline == *guestfs_rescue=1* ]]; then - guestfs_rescue=1 -fi -if [[ $cmdline == *guestfs_noreboot=1* ]]; then - guestfs_noreboot=1 -fi -eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline` - # Set up the network. ip addr add 127.0.0.1/8 brd + dev lo scope host ip link set dev lo up @@ -156,6 +158,7 @@ fi if ! test "$guestfs_rescue" = 1; then # Run the daemon. cmd="guestfsd" + eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline` if test "x$guestfs_channel" != "x"; then cmd="$cmd --channel $guestfs_channel" fi -- 2.7.4