Blame SOURCES/0189-Add-rd.cmdline-ask-kernel-command-line-parameter.patch

a56a5e
From 9c2daa5d3aa1b98d5a005a78a7a2d332e7422034 Mon Sep 17 00:00:00 2001
a56a5e
From: Harald Hoyer <harald@redhat.com>
a56a5e
Date: Fri, 27 Jun 2014 12:02:14 +0200
a56a5e
Subject: [PATCH] Add "rd.cmdline=ask" kernel command line parameter
a56a5e
a56a5e
prompts the user for additional kernel command line parameters
a56a5e
a56a5e
(cherry picked from commit f232f6623d2b761c1538192c97e13842e5037adc)
a56a5e
a56a5e
Conflicts:
a56a5e
	dracut.cmdline.7.asc
a56a5e
	modules.d/98systemd/dracut-cmdline.sh
a56a5e
	modules.d/99base/init.sh
a56a5e
---
a56a5e
 dracut.cmdline.7.asc                           |  4 ++++
a56a5e
 modules.d/98systemd/dracut-cmdline-ask.service | 33 ++++++++++++++++++++++++++
a56a5e
 modules.d/98systemd/dracut-cmdline-ask.sh      | 20 ++++++++++++++++
a56a5e
 modules.d/98systemd/module-setup.sh            |  2 ++
a56a5e
 modules.d/99base/init.sh                       |  8 +++++++
a56a5e
 5 files changed, 67 insertions(+)
a56a5e
 create mode 100644 modules.d/98systemd/dracut-cmdline-ask.service
a56a5e
 create mode 100755 modules.d/98systemd/dracut-cmdline-ask.sh
a56a5e
a56a5e
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
1755ca
index 10550eef..24bf4491 100644
a56a5e
--- a/dracut.cmdline.7.asc
a56a5e
+++ b/dracut.cmdline.7.asc
a56a5e
@@ -81,6 +81,10 @@ rootfstype=ext3
a56a5e
     enable autoassembly of special devices like cryptoLUKS, dmraid, mdraid or
a56a5e
     lvm. Default is off as of dracut version >= 024.
a56a5e
 
a56a5e
+
a56a5e
+**rd.cmdline=ask**::
a56a5e
+    prompts the user for additional kernel command line parameters
a56a5e
+
a56a5e
 **rd.fstab=0**::
a56a5e
     do not honor special mount options for the root filesystem found in
a56a5e
     _/etc/fstab_ of the real root.
a56a5e
diff --git a/modules.d/98systemd/dracut-cmdline-ask.service b/modules.d/98systemd/dracut-cmdline-ask.service
a56a5e
new file mode 100644
1755ca
index 00000000..9993671c
a56a5e
--- /dev/null
a56a5e
+++ b/modules.d/98systemd/dracut-cmdline-ask.service
a56a5e
@@ -0,0 +1,33 @@
a56a5e
+#  This file is part of systemd.
a56a5e
+#
a56a5e
+#  systemd is free software; you can redistribute it and/or modify it
a56a5e
+#  under the terms of the GNU Lesser General Public License as published by
a56a5e
+#  the Free Software Foundation; either version 2.1 of the License, or
a56a5e
+#  (at your option) any later version.
a56a5e
+
a56a5e
+# See systemd.special(7) for details
a56a5e
+
a56a5e
+[Unit]
a56a5e
+Description=dracut ask for additional cmdline parameters
a56a5e
+DefaultDependencies=no
a56a5e
+Before=dracut-cmdline.service
a56a5e
+After=systemd-journald.socket
a56a5e
+Wants=systemd-journald.socket
a56a5e
+ConditionPathExists=/etc/initrd-release
a56a5e
+ConditionKernelCommandLine=rd.cmdline=ask
a56a5e
+
a56a5e
+[Service]
a56a5e
+Environment=DRACUT_SYSTEMD=1
a56a5e
+Environment=NEWROOT=/sysroot
a56a5e
+Type=oneshot
a56a5e
+ExecStart=-/bin/dracut-cmdline-ask
a56a5e
+StandardInput=tty
a56a5e
+StandardOutput=inherit
a56a5e
+StandardError=inherit
a56a5e
+RemainAfterExit=yes
a56a5e
+KillMode=process
a56a5e
+IgnoreSIGPIPE=no
a56a5e
+
a56a5e
+# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
a56a5e
+# terminates cleanly.
a56a5e
+KillSignal=SIGHUP
a56a5e
diff --git a/modules.d/98systemd/dracut-cmdline-ask.sh b/modules.d/98systemd/dracut-cmdline-ask.sh
a56a5e
new file mode 100755
1755ca
index 00000000..024d60ee
a56a5e
--- /dev/null
a56a5e
+++ b/modules.d/98systemd/dracut-cmdline-ask.sh
a56a5e
@@ -0,0 +1,20 @@
a56a5e
+#!/bin/bash
a56a5e
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
a56a5e
+# ex: ts=8 sw=4 sts=4 et filetype=sh
a56a5e
+
a56a5e
+sleep 0.5
a56a5e
+echo
a56a5e
+sleep 0.5
a56a5e
+echo
a56a5e
+sleep 0.5
a56a5e
+echo
a56a5e
+echo
a56a5e
+echo
a56a5e
+echo
a56a5e
+echo "Enter additional kernel command line parameter (end with ctrl-d or .)"
a56a5e
+while read -e -p "> " line; do
a56a5e
+    [[ "$line" == "." ]] && break
a56a5e
+    [[ "$line" ]] && printf -- "%s\n" "$line" >> /etc/cmdline.d/99-cmdline-ask.conf
a56a5e
+done
a56a5e
+
a56a5e
+exit 0
a56a5e
diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh
1755ca
index 0de9d614..015597f4 100755
a56a5e
--- a/modules.d/98systemd/module-setup.sh
a56a5e
+++ b/modules.d/98systemd/module-setup.sh
a56a5e
@@ -183,6 +183,7 @@ install() {
a56a5e
     ln_r "${systemdsystemunitdir}/initrd.target" "${systemdsystemunitdir}/default.target"
a56a5e
 
a56a5e
     inst_script "$moddir/dracut-cmdline.sh" /bin/dracut-cmdline
a56a5e
+    inst_script "$moddir/dracut-cmdline-ask.sh" /bin/dracut-cmdline-ask
a56a5e
     inst_script "$moddir/dracut-pre-udev.sh" /bin/dracut-pre-udev
a56a5e
     inst_script "$moddir/dracut-pre-trigger.sh" /bin/dracut-pre-trigger
a56a5e
     inst_script "$moddir/dracut-initqueue.sh" /bin/dracut-initqueue
a56a5e
@@ -212,6 +213,7 @@ install() {
a56a5e
     mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
a56a5e
     for i in \
a56a5e
         dracut-cmdline.service \
a56a5e
+        dracut-cmdline-ask.service \
a56a5e
         dracut-initqueue.service \
a56a5e
         dracut-mount.service \
a56a5e
         dracut-pre-mount.service \
a56a5e
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
1755ca
index ae73fd2c..9ee3e9dc 100755
a56a5e
--- a/modules.d/99base/init.sh
a56a5e
+++ b/modules.d/99base/init.sh
a56a5e
@@ -115,6 +115,14 @@ fi
a56a5e
 
a56a5e
 source_conf /etc/conf.d
a56a5e
 
a56a5e
+if getarg "rd.cmdline=ask"; then
a56a5e
+    echo "Enter additional kernel command line parameter (end with ctrl-d or .)"
a56a5e
+    while read -p "> " line; do
a56a5e
+        [ "$line" = "." ] && break
a56a5e
+        echo "$line" >> /etc/cmdline.d/99-cmdline-ask.conf
a56a5e
+    done
a56a5e
+fi
a56a5e
+
a56a5e
 # run scriptlets to parse the command line
a56a5e
 make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
a56a5e
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"