|
|
e76f14 |
From 2bb0c9f0596ef616992a248dec535c3dffc0337d Mon Sep 17 00:00:00 2001
|
|
|
e76f14 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
e76f14 |
Date: Sat, 19 Mar 2016 18:27:07 +0000
|
|
|
e76f14 |
Subject: [PATCH] appliance: init: Move cmdline parsing earlier.
|
|
|
e76f14 |
|
|
|
e76f14 |
Since commit bb5d30ab2af5720775c63179afdec3ad9efd510d, we don't
|
|
|
e76f14 |
require any external programs like grep to parse the command line. We
|
|
|
e76f14 |
only use bash intrinsics.
|
|
|
e76f14 |
|
|
|
e76f14 |
Therefore we can do it early (but after /proc is mounted).
|
|
|
e76f14 |
|
|
|
e76f14 |
This allows verbose mode to enable set -x early on, so we can trace
|
|
|
e76f14 |
most things that the init script does.
|
|
|
e76f14 |
|
|
|
e76f14 |
(cherry picked from commit cb8f69e95929e512fcb8882ffb647dc72fc4a865)
|
|
|
e76f14 |
---
|
|
|
e76f14 |
appliance/init | 39 +++++++++++++++++++++------------------
|
|
|
e76f14 |
1 file changed, 21 insertions(+), 18 deletions(-)
|
|
|
e76f14 |
|
|
|
e76f14 |
diff --git a/appliance/init b/appliance/init
|
|
|
e76f14 |
index 239b50e..55b1a35 100755
|
|
|
e76f14 |
--- a/appliance/init
|
|
|
e76f14 |
+++ b/appliance/init
|
|
|
e76f14 |
@@ -33,9 +33,29 @@ done
|
|
|
e76f14 |
|
|
|
e76f14 |
mkdir -p /sysroot
|
|
|
e76f14 |
|
|
|
e76f14 |
+# Mount /proc.
|
|
|
e76f14 |
if [ ! -d /proc ]; then rm -f /proc; fi
|
|
|
e76f14 |
mkdir -p /proc
|
|
|
e76f14 |
mount -t proc /proc /proc
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+# Parse the kernel command line early (must be after /proc is mounted).
|
|
|
e76f14 |
+cmdline=$(
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+if [[ $cmdline == *guestfs_verbose=1* ]]; then
|
|
|
e76f14 |
+ guestfs_verbose=1
|
|
|
e76f14 |
+ set -x
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+if [[ $cmdline == *guestfs_network=1* ]]; then
|
|
|
e76f14 |
+ guestfs_network=1
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+if [[ $cmdline == *guestfs_rescue=1* ]]; then
|
|
|
e76f14 |
+ guestfs_rescue=1
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+if [[ $cmdline == *guestfs_noreboot=1* ]]; then
|
|
|
e76f14 |
+ guestfs_noreboot=1
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+# Mount the other special filesystems.
|
|
|
e76f14 |
if [ ! -d /sys ]; then rm -f /sys; fi
|
|
|
e76f14 |
mkdir -p /sys
|
|
|
e76f14 |
mount -t sysfs /sys /sys
|
|
|
e76f14 |
@@ -77,8 +97,6 @@ $UDEVD --daemon #--debug
|
|
|
e76f14 |
udevadm trigger
|
|
|
e76f14 |
udevadm settle --timeout=600
|
|
|
e76f14 |
|
|
|
e76f14 |
-cmdline=$(
|
|
|
e76f14 |
-
|
|
|
e76f14 |
if [[ $cmdline == *selinux=1* ]]; then
|
|
|
e76f14 |
mount -t selinuxfs none /sys/fs/selinux
|
|
|
e76f14 |
fi
|
|
|
e76f14 |
@@ -94,22 +112,6 @@ shopt -u nullglob
|
|
|
e76f14 |
# Update the system clock.
|
|
|
e76f14 |
hwclock -u -s
|
|
|
e76f14 |
|
|
|
e76f14 |
-# Parse the kernel command line.
|
|
|
e76f14 |
-if [[ $cmdline == *guestfs_verbose=1* ]]; then
|
|
|
e76f14 |
- guestfs_verbose=1
|
|
|
e76f14 |
- set -x
|
|
|
e76f14 |
-fi
|
|
|
e76f14 |
-if [[ $cmdline == *guestfs_network=1* ]]; then
|
|
|
e76f14 |
- guestfs_network=1
|
|
|
e76f14 |
-fi
|
|
|
e76f14 |
-if [[ $cmdline == *guestfs_rescue=1* ]]; then
|
|
|
e76f14 |
- guestfs_rescue=1
|
|
|
e76f14 |
-fi
|
|
|
e76f14 |
-if [[ $cmdline == *guestfs_noreboot=1* ]]; then
|
|
|
e76f14 |
- guestfs_noreboot=1
|
|
|
e76f14 |
-fi
|
|
|
e76f14 |
-eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline`
|
|
|
e76f14 |
-
|
|
|
e76f14 |
# Set up the network.
|
|
|
e76f14 |
ip addr add 127.0.0.1/8 brd + dev lo scope host
|
|
|
e76f14 |
ip link set dev lo up
|
|
|
e76f14 |
@@ -157,6 +159,7 @@ fi
|
|
|
e76f14 |
if ! test "$guestfs_rescue" = 1; then
|
|
|
e76f14 |
# Run the daemon.
|
|
|
e76f14 |
cmd="guestfsd"
|
|
|
e76f14 |
+ eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline`
|
|
|
e76f14 |
if test "x$guestfs_channel" != "x"; then
|
|
|
e76f14 |
cmd="$cmd --channel $guestfs_channel"
|
|
|
e76f14 |
fi
|
|
|
e76f14 |
--
|
|
|
e76f14 |
1.8.3.1
|
|
|
e76f14 |
|