Generate /etc/kernel/cmdline if it does not exist
Don't fall back to reading /proc/cmdline: that will likely reflect the installer environment which will result in a non-booting kernel entry. See-also: rhbz#1940288 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
parent
c33643ba10
commit
77693cd7eb
@ -76,16 +76,24 @@ case "$COMMAND" in
|
|||||||
|
|
||||||
if [[ ! -f /sbin/new-kernel-pkg || -d "${BLS_DIR}" ]]; then
|
if [[ ! -f /sbin/new-kernel-pkg || -d "${BLS_DIR}" ]]; then
|
||||||
declare -a BOOT_OPTIONS
|
declare -a BOOT_OPTIONS
|
||||||
|
if [[ ! -f /etc/kernel/cmdline ]]; then
|
||||||
|
last=''
|
||||||
|
for entry in "${BLS_DIR}"/*.conf; do
|
||||||
|
last="$entry"
|
||||||
|
done
|
||||||
|
if [[ ! -z "$last" ]]; then
|
||||||
|
args="$(awk '/options/{$1="";$0=$0;$1=$1;print}' $last)"
|
||||||
|
echo "$args" > /etc/kernel/cmdline
|
||||||
|
fi
|
||||||
|
fi
|
||||||
if [[ -f /etc/kernel/cmdline ]]; then
|
if [[ -f /etc/kernel/cmdline ]]; then
|
||||||
read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
|
read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ ${BOOT_OPTIONS[*]} ]]; then
|
if ! [[ ${BOOT_OPTIONS[*]} ]]; then
|
||||||
read -r -d '' -a line < /proc/cmdline
|
echo "Could not determine the kernel command line parameters." >&2
|
||||||
for i in "${line[@]}"; do
|
echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
|
||||||
[[ "${i#initrd=*}" != "$i" || "${i#BOOT_IMAGE=*}" != "$i" ]] && continue
|
exit 1
|
||||||
BOOT_OPTIONS+=("$i")
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR"
|
[[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user