15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Peter Jones <pjones@redhat.com>
15a2072
Date: Fri, 22 Jun 2018 14:01:06 -0400
15a2072
Subject: [PATCH] grub-switch-to-blscfg.in: get rid of a bunch of bashisms
15a2072
15a2072
Since this says /bin/sh at the top, it should work with dash.
15a2072
15a2072
Signed-off-by: Peter Jones <pjones@redhat.com>
15a2072
---
15a2072
 util/grub-switch-to-blscfg.in | 30 +++++++++++++++---------------
15a2072
 1 file changed, 15 insertions(+), 15 deletions(-)
15a2072
15a2072
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
15a2072
index 2482483a437..dac41e73836 100644
15a2072
--- a/util/grub-switch-to-blscfg.in
15a2072
+++ b/util/grub-switch-to-blscfg.in
15a2072
@@ -151,18 +151,18 @@ done
15a2072
 
15a2072
 find_grub_cfg() {
15a2072
     local candidate=""
15a2072
-    while [[ -e "${candidate}" || $# -gt 0 ]]
15a2072
+    while [ -e "${candidate}" -o $# -gt 0 ]
15a2072
     do
15a2072
-        if [[ ! -e "${candidate}" ]] ; then
15a2072
+        if [ ! -e "${candidate}" ] ; then
15a2072
             candidate="$1"
15a2072
             shift
15a2072
         fi
15a2072
 
15a2072
-        if [[ -L "${candidate}" ]]; then
15a2072
+        if [ -L "${candidate}" ]; then
15a2072
             candidate="$(realpath "${candidate}")"
15a2072
         fi
15a2072
 
15a2072
-        if [[ -f "${candidate}" ]]; then
15a2072
+        if [ -f "${candidate}" ]; then
15a2072
             export GRUB_CONFIG_FILE="${candidate}"
15a2072
             return 0
15a2072
         fi
15a2072
@@ -175,11 +175,11 @@ if ! find_grub_cfg ${startlink} ${grubdir}/grub.cfg ; then
15a2072
   exit 1
15a2072
 fi
15a2072
 
15a2072
-if [[ ! -d "${blsdir}" ]]; then
15a2072
+if [ ! -d "${blsdir}" ]; then
15a2072
     install -m 700 -d "${blsdir}"
15a2072
 fi
15a2072
 
15a2072
-if [[ -f /etc/machine-id ]]; then
15a2072
+if [ -f /etc/machine-id ]; then
15a2072
     MACHINE_ID=$(cat /etc/machine-id)
15a2072
 else
15a2072
     MACHINE_ID=$(dmesg | sha256sum)
15a2072
@@ -194,9 +194,9 @@ mkbls() {
15a2072
     local debugid=""
15a2072
     local flavor=""
15a2072
 
15a2072
-    if [[ "$kernelver" == *\+* ]] ; then
15a2072
+    if [ "$kernelver" == *\+* ] ; then
15a2072
         local flavor=-"${kernelver##*+}"
15a2072
-        if [[ "${flavor}" == "-debug" ]]; then
15a2072
+        if [ "${flavor}" == "-debug" ]; then
15a2072
             local debugname=" with debugging"
15a2072
             local debugid="-debug"
15a2072
         fi
15a2072
@@ -219,15 +219,15 @@ EOF
15a2072
 }
15a2072
 
15a2072
 for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
-    if [[ ! -d "/lib/modules/${kernelver}" ]] ; then
15a2072
+    if [ ! -d "/lib/modules/${kernelver}" ] ; then
15a2072
         continue
15a2072
     fi
15a2072
-    if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then
15a2072
+    if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then
15a2072
         continue
15a2072
     fi
15a2072
     bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
15a2072
     kernel_dir="/lib/modules/${kernelver}"
15a2072
-    if [[ -f "${kernel_dir}/bls.conf" ]]; then
15a2072
+    if [ -f "${kernel_dir}/bls.conf" ]; then
15a2072
         cp -af "${kernel_dir}/bls.conf" "${bls_target}"
15a2072
     else
15a2072
         mkbls "${kernelver}" \
15a2072
@@ -240,7 +240,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
     linux_relpath="$("${grub_mkrelpath}" /boot/$linux)"
15a2072
     initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)"
15a2072
 
15a2072
-    if [[ $linux != $linux_relpath ]]; then
15a2072
+    if [ $linux != $linux_relpath ] ; then
15a2072
         sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}"
15a2072
         sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}"
15a2072
     fi
15a2072
@@ -257,8 +257,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
     fi
15a2072
 done
15a2072
 
15a2072
-if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then
15a2072
-    if [[ $linux != $linux_relpath ]]; then
15a2072
+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
15a2072
+    if [ $linux != $linux_relpath ]; then
15a2072
         bootprefix="$(dirname ${linux_relpath})"
15a2072
     fi
15a2072
     mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
15a2072
@@ -282,7 +282,7 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then
15a2072
     GENERATE=1
15a2072
 fi
15a2072
 
15a2072
-if [[ "${GENERATE}" -eq 1 ]] ; then
15a2072
+if [ "${GENERATE}" -eq 1 ] ; then
15a2072
     cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
15a2072
     if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
15a2072
         cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"