From 3f14137bc017a27a9908c389f066b1c400eb6d81 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 28 Jul 2013 16:20:08 +0200 Subject: [PATCH] linuxrc: create is_livecd(), stop doing weird ${CDROOT} comparisons --- defaults/initrd.scripts | 15 ++++++++++----- defaults/linuxrc | 11 ++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 943d912..00ea3e6 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -209,8 +209,13 @@ uppercase() { echo $1 | tr 'a-z' 'A-Z' } +is_livecd() { + [ "${CDROOT}" = "1" ] && return 0 + return 1 +} + setup_real_root() { - if [ "${CDROOT}" = '0' ] + if ! is_livecd then if [ -z "${REAL_ROOT}" -a "${FAKE_ROOT}" != "/dev/ram0" ] then @@ -435,7 +440,7 @@ findnfsmount() { NFSOPTIONS="${DEFAULT_NFSOPTIONS},${NFSOPTIONS}" fi - if [ "${CDROOT}" != '0' ] + if is_livecd then good_msg "Attempting to mount NFS CD image on ${NFSROOT} with options ${NFSOPTIONS}" mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${CDROOT_PATH} @@ -816,7 +821,7 @@ setup_keymap() { [ "${DEVBIND}" = '1' ] && umount /dev - if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" = '1' ] + if [ -e /etc/sysconfig/keyboard ] && is_livecd then mkdir -p ${NEW_ROOT}/etc/sysconfig/ cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard @@ -1314,7 +1319,7 @@ sdelay() { then good_msg "Waiting ${SDELAY} seconds..." sleep ${SDELAY} - elif [ "${CDROOT}" = '1' ] + elif is_livecd then good_msg 'Hint: Use scandelay[=seconds] if your live medium is slowand boot fails' fi @@ -1332,7 +1337,7 @@ verbose_kmsg() { cdupdate() { - if [ "${CDROOT}" = '1' ] + if is_livecd then if [ -x /${CDROOT_PATH}/cdupdate.sh ] then diff --git a/defaults/linuxrc b/defaults/linuxrc index dce82ad..02184ed 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -281,12 +281,9 @@ start_volumes setup_keymap # Initialize LUKS root device except for livecd's -if [ "${CDROOT}" != 1 ] -then - start_luks -fi +is_livecd || start_luks -if [ "${CDROOT}" != 1 ] +if ! is_livecd then if [ "${NORESUME}" != '1' ] && [ -n "${REAL_RESUME}" ] then @@ -328,7 +325,7 @@ CHROOT="${NEW_ROOT}" # Run debug shell if requested rundebugshell "before setting up the root filesystem" -if [ "${CDROOT}" = '1' ] +if is_livecd then good_msg "Making tmpfs for ${NEW_ROOT}" mount -n -t tmpfs tmpfs "${NEW_ROOT}" @@ -554,7 +551,7 @@ done # End determine root device # If CD root is set determine the looptype to boot -if [ "${CDROOT}" = '1' ] +if is_livecd then good_msg 'Determining looptype ...' cd "${NEW_ROOT}"