HIRS/.ci/system-tests/container/pc_setup.sh

58 lines
2.3 KiB
Bash
Raw Normal View History

#!/bin/bash
#########################################################################################
2022-02-02 15:53:46 +00:00
# Setup for platform certificates for testing
# Copies platform certs (Base and Delta) to the tcg directory
# usage pc_setup.sh <profile> <test>
#########################################################################################
profile=$1
test=$2
2022-02-03 20:30:10 +00:00
tcgDir="/boot/tcg"
compscript="$profile"_"$test"_allcomponents.sh
hwlist="$profile"_"$test"_hw.json
2022-02-03 20:30:10 +00:00
testDir="/HIRS/.ci/system-tests/profiles/$profile/$test"
pcDir=$testDir/platformcerts
profileDir="/HIRS/.ci/system-tests/profiles/$profile"
2022-02-02 15:53:46 +00:00
# Current TCG folder for platform certs, likely to change with release of the next FIM specification
tcgDir=/boot/tcg/cert/platform/
mkdir -p $tcgDir; # Create the platform cert folder if its not there
rm -f $tcgDir*; # Clear out any previous data
2022-01-12 15:26:52 +00:00
echo "Test is using platform cert(s) from $profile : $test"
2022-02-01 23:27:05 +00:00
# Step 1: Copy allcomponents script to the paccor/scripts folder if there is one.
# Use the default if test does not have a test specific file.
2022-02-01 23:27:05 +00:00
allCompScript=/HIRS/.ci/system-tests/profiles/$profile/$test/$compscript
2022-02-02 13:41:05 +00:00
if [ ! -f "$allCompScript" ]; then
2022-02-01 23:27:05 +00:00
allCompScript=/HIRS/.ci/system-tests/profiles/"$profile"/default/"$profile"_default_allcomponents.sh
fi
cp -f $allCompScript /opt/paccor/scripts/allcomponents.sh;
# Step 2: Copy allcomponents json file to the paccor/scripts folder if there is one
# Use the default if test does not have a test specific file.
2022-02-01 23:42:27 +00:00
allCompJson=/HIRS/.ci/system-tests/profiles/$profile/$test/$hwlist;
2022-02-01 23:27:05 +00:00
if [ ! -f "$allCompJson" ]; then
allCompJson=/HIRS/.ci/system-tests/profiles/"$profile"/default/"$profile"_default_hw.json
fi
cp -f $allCompJson /opt/paccor/scripts/$hwlist ;
2022-01-10 20:13:51 +00:00
# Step 3: Copy the platform cert to tcg folder on boot drive
2022-02-03 20:30:10 +00:00
# a: See if test specific swidtag folder exists, if not use the defualt folder
if [[ ! -d $pcDir ]]; then
pcDir=$profileDir/default/platformcerts;
fi
pushd $pcDir > /dev/null
2022-02-02 15:53:46 +00:00
# Skip copy of platform cert if .gitigore exists (empty profile)
2022-01-12 15:26:52 +00:00
if [[ ! -f ".gitignore" ]]; then
for cert in * ; do
2022-02-02 15:53:46 +00:00
cp -f $cert $tcgDir$cert;
done
2022-01-12 15:26:52 +00:00
fi
2022-01-10 20:13:51 +00:00
popd > /dev/null
# Step 4: Make some data available for debugging
2022-01-10 20:13:51 +00:00
bash /opt/paccor/scripts/allcomponents.sh > /var/log/hirs/provisioner/allcomponents.output.log