176 lines
5.3 KiB
INI
176 lines
5.3 KiB
INI
%post --nochroot --erroronfail
|
|
|
|
# Source common functions
|
|
. /tmp/ks-functions.sh
|
|
KS="Prestaging post:"
|
|
|
|
#
|
|
# The /tmp/backup-guid-change.sh script assignes the Label
|
|
# and GUID to the Platform Backup partition. This script is
|
|
# dynamically created in the pre_disk_aio.cfg kickstart, which
|
|
# serves as the disk setup kickstart for the prestaging bundle.
|
|
#
|
|
# However, this script is only run afterward; in post_common.cfg
|
|
# which is not used in the prestaging bundle ; it contains too
|
|
# much in-service controller function setup stuff.
|
|
#
|
|
# Therefore, it is added here to ensure that if the prestaging
|
|
# ISO's pre_disk_aio.cfg 'created' the 'Platform Backup'
|
|
# partition then it will get labeled for prestaging group.
|
|
#
|
|
# This prestaging kickstart file uses the 'label' to find the
|
|
# 'Platform Backup' partition for its prestaging function.
|
|
#
|
|
change_guid=/tmp/backup-guid-change.sh
|
|
if [ -f "$change_guid" ]; then
|
|
wlog "${KS} applying label to backup partition"
|
|
sh $change_guid || report_post_failure_with_logfile "ERROR: Failed to update platform backup label and GUID"
|
|
else
|
|
wlog "${KS} /tmp/backup-guid-change.sh not found !!"
|
|
fi
|
|
|
|
%end
|
|
|
|
%post --nochroot --erroronfail
|
|
|
|
# Source common functions
|
|
. /tmp/ks-functions.sh
|
|
KS="Prestaging post:"
|
|
|
|
error=false
|
|
|
|
wlog "${KS} cmdLine: $(cat /proc/cmdline)"
|
|
|
|
if [ -d /mnt/install/source ]; then
|
|
SOURCE_DIR=/mnt/install/source
|
|
else
|
|
SOURCE_DIR=/run/install/repo
|
|
fi
|
|
wlog "${KS} install source : $SOURCE_DIR"
|
|
|
|
export SW_VERSION=xxxPLATFORM_RELEASExxx
|
|
export STAGING_DIR="platform-backup"
|
|
export PRESTAGING_PART_LABEL=Platform\\x20Backup
|
|
export PRESTAGING_DEVICE=/dev/disk/by-partlabel/${PRESTAGING_PART_LABEL}
|
|
export PRESTAGING_REPO_DIR="${SOURCE_DIR}/opt/${STAGING_DIR}"
|
|
export PRESTAGING_LOCAL_DIR="/mnt/${STAGING_DIR}"
|
|
|
|
wlog "${KS} SW_VERSION : ${SW_VERSION}"
|
|
wlog "${KS} IMAGE_MOUNT : ${SOURCE_DIR}"
|
|
wlog "${KS} PRESTAGING_REPO_DIR : ${PRESTAGING_REPO_DIR}"
|
|
wlog "${KS} PRESTAGING_LOCAL_DIR : ${PRESTAGING_LOCAL_DIR}"
|
|
|
|
# check for required directories
|
|
if [ ! -d ${SOURCE_DIR} ] ; then
|
|
msg="install source '${SOURCE_DIR}' does not exists or is not a directory"
|
|
wlog "${KS} Prestaging Failed: ${msg}"
|
|
report_pre_failure_with_msg "${msg}"
|
|
elif [ ! -d "${PRESTAGING_REPO_DIR}" ] ; then
|
|
msg="repo ${PRESTAGING_REPO_DIR} does not exist"
|
|
wlog "${KS} Prestaging Failed: ${msg}"
|
|
report_pre_failure_with_msg "${msg}"
|
|
elif [ ! -d "${PRESTAGING_REPO_DIR}/${SW_VERSION}" ] ; then
|
|
msg="repo ${PRESTAGING_REPO_DIR}/${SW_VERSION} sw version content missing"
|
|
wlog "${KS} Prestaging Failed: ${msg}"
|
|
report_prestaging_failure_with_msg "${msg}"
|
|
fi
|
|
|
|
# Poll for the Platform Backup partition label.
|
|
# TODO: Turn this into a function.
|
|
found=false
|
|
for i in {1..6} ; do
|
|
|
|
files=$(ls /dev/disk/by-partlabel)
|
|
for file in $files ; do
|
|
if [ "$file" == "Platform\x20Backup" ] ; then
|
|
if [ ${i} -gt 1 ] ; then
|
|
wlog "${KS} prestaging partition label found in ${i} audit"
|
|
fi
|
|
found=true
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ "$found" = true ] ; then
|
|
break
|
|
else
|
|
wlog "${KS} searching for 'Platform\x20Backup' label ${i}"
|
|
sleep 10
|
|
fi
|
|
done
|
|
|
|
# if the label is not visable yet then we will see it in a mount failure
|
|
if [ ! -d "${PRESTAGING_LOCAL_DIR}" ] ; then
|
|
wlog "${KS} mounting ${PRESTAGING_LOCAL_DIR}"
|
|
mkdir -p ${PRESTAGING_LOCAL_DIR}
|
|
mount ${PRESTAGING_DEVICE} ${PRESTAGING_LOCAL_DIR}
|
|
rc=$?
|
|
if [ $rc -eq 0 ] ; then
|
|
sleep 2
|
|
if [ ! -d "${PRESTAGING_LOCAL_DIR}" ] ; then
|
|
wlog "${KS} mount of staging '${PRESTAGING_LOCAL_DIR}' does not exist"
|
|
error=true
|
|
else
|
|
error=false
|
|
fi
|
|
else
|
|
wlog "${KS} mount of '${PRESTAGING_DEVICE}' to '${PRESTAGING_LOCAL_DIR}' failed rc:${rc}"
|
|
error=true
|
|
fi
|
|
fi
|
|
|
|
if [ "$error" = true ] ; then
|
|
msg="Unable to mount ${PRESTAGING_LOCAL_DIR}"
|
|
wlog "${KS} Prestaging failed: ${msg}"
|
|
report_prestaging_failure_with_msg "${msg}"
|
|
fi
|
|
|
|
# nuke local prestaging dir - cleanup operation
|
|
if [ -d ${PRESTAGING_LOCAL_DIR}/${SW_VERSION} ] ; then
|
|
wlog "${KS} wiping prestaging dir '${PRESTAGING_LOCAL_DIR}/${SW_VERSION}'"
|
|
rm -rf ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
|
fi
|
|
|
|
# create local prestaging dir
|
|
mkdir ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
|
|
|
# enter the local prestaging dir for this release
|
|
cd ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
|
|
|
# copy repo prestaging files to the local mount
|
|
wlog "${KS} copy prestaging files"
|
|
cp -a ${PRESTAGING_REPO_DIR}/${SW_VERSION} ${PRESTAGING_LOCAL_DIR}
|
|
wlog "${KS} prestaging files copy done"
|
|
|
|
# loop over all the prestaged files
|
|
# - log files found
|
|
# - do md5 check on md5 files found
|
|
for file in * ; do
|
|
filename="${file%.*}"
|
|
extension="${file##*.}"
|
|
wlog "${KS} prestaged file : ${file}"
|
|
if [ "${extension}" = "md5" ] ; then
|
|
md5sum -c "${file}"
|
|
if [ $? -eq 0 ] ; then
|
|
wlog "${KS} ${filename} check passed"
|
|
else
|
|
wlog "${KS} ${filename} check failed"
|
|
error=true
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# handle any md5 check errors or log success/complete result
|
|
if [ "$error" = true ] ; then
|
|
msg="prestaging file(s) failed integrity check ; see logs for details"
|
|
wlog "${KS} Prestaging failed: ${msg}"
|
|
report_prestaging_failure_with_msg "${msg}"
|
|
else
|
|
wlog "${KS} prestaging integrity checks passed"
|
|
fi
|
|
|
|
wlog "${KS} prestaging complete"
|
|
|
|
%end
|
|
|