Fix prestage ISO install abort if previous subcloud install exists

This commit fixes the detection of www/pages/feed/rel-xx.x/install_uuid
via device '/dev/cgts-vg/var-lv'. There was a bug which was always
mounting the same device, rather than the proper device_list.

The code is also slightly refactored for simplification and clarity.

Test Plan
PASS:
- Generate ISO using gen-prestage-iso.sh without --force-install option
    - Verify installation failure (drop to boot prompt) if previous
      subcloud installation exists
    - Verify successful subcloud installation if no previous
      subcloud installation exists
- Generate ISO using gen-prestage-iso.sh with --force-install option
    - Verify successful installation regardless if previous subcloud
      installation exists or not

Closes-Bug: 2020526
Change-Id: Ib83d72fa07335ffa29d365da7813b226c4ef310b
Signed-off-by: Kyle MacLeod <kyle.macleod@windriver.com>
This commit is contained in:
Kyle MacLeod 2023-05-19 21:24:45 -04:00
parent 1455771c9c
commit d807f6b65e
1 changed files with 16 additions and 18 deletions

View File

@ -1103,30 +1103,28 @@ if check_prestage -eq 0 ; then
ilog "Searching for existing installation..."
device_list=()
# Build up device_list to search for existing installation.
# We will look for the install_uuid file on each of the devices in the list.
# First, if volume groups have been enabled, we can mount /dev/cgts-vg/var-lv
device_list=("/dev/cgts-vg/var-lv")
# Now add the rest of the rootfs partitions to device_list
for part in "${part_numbers[@]}"; do
device=${rootfs_part_prefix}${part}
device_list+=(${device})
ilog "Adding ${device}"
device_list+=("${rootfs_part_prefix}${part}")
done
# adding the following device to the device list to search
# for the filesystem. If Volume Groups have been enabled,
# it is possible to perform the checks for install_guid below
# by mounting /dev/cgts-vg/var-lv.
device_list+=("/dev/cgts-vg/var-lv")
ilog "Adding /dev/cgts-vg/var-lv"
for part in "${device_list[@]}"; do
ilog "Checking device_list: ${device_list[*]}"
for device in "${device_list[@]}"; do
# mount this part at a temporary mount point
mount ${device} ${temp_mount}
if [ $? -ne 0 ]; then
wlog "Unable to mount ${device}"
ilog "Checking device: ${device}"
mount "${device}" "${temp_mount}"
rc=$?
if [ "${rc}" -ne 0 ]; then
wlog "Unable to mount ${device}, rc=${rc}"
continue
fi
# Check for the presence of install_uuid in one of the partitions on
# the root device
if [[ -e "${temp_mount}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid" ]]; then
# Check for the presence of install_uuid in one of the partitions on the device_list
if [ -e "${temp_mount}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid" ]; then
wlog "Found valid installation on ${device}"
umount ${temp_mount}
# Do not modify the system in any way