Index: scripts/generate_config_files_sha.sh =================================================================== diff -u -rf41e349e9736828dd60984f27bb558dc16cd7e03 -re59f07f461b51e8d63822b868e3af3f4e38dde04 --- scripts/generate_config_files_sha.sh (.../generate_config_files_sha.sh) (revision f41e349e9736828dd60984f27bb558dc16cd7e03) +++ scripts/generate_config_files_sha.sh (.../generate_config_files_sha.sh) (revision e59f07f461b51e8d63822b868e3af3f4e38dde04) @@ -14,27 +14,43 @@ # @date (original) 25-Jul-2023 # ############################################################################ -# $1 - the path to the settings folder +# $1 - the path to the settings folder, locally # $2 - The path of where conf files live on the device -# $3 - output sha file path (eg: /home/root/settings.crc) - # NOTE: The expectation is the configuration files are in a parent folder settings # eg. $HOME/project/application/resources/settings/ -if [ $# -lt 3 ]; then +SRC_SETTINGS_LOCAL=$1 + +DST_SETTINGS_CRC=/home/denali/.config/settings.crc +DST_SETTINGS_ON_DEVICE=$2 + + +if [ $# -lt 2 ]; then currentFile=$(basename "$0") echo "Usage: ./$currentFile " exit 1003 fi -# find all .conf files in the given path -find $1 -type f -name '*.conf' -exec sha256sum {} \; > "$3" +# Excluding System.conf from search result +# Includes the .dflt / default extensioned files +find "$SRC_SETTINGS_LOCAL" -type f -name '*[.conf|.dflt]' ! -name "System.conf" -exec sha256sum {} \; > "$DST_SETTINGS_CRC" -# strip it of the absolute path string -sed -i "s+ .*$1+ $2/+g" $3 +if [ $? -ne 0 ]; then + echo "Generation of SHA file failed." + exit 1002 +fi + +# Update the generated sha file to reflect path on device +# The sha256sum command ouputs : +# 031478493a016b31d6fa86dbcd4a95d114e307a7cadc46b4ab5fe8e232256229 someBuildFolder/Instructions/Instructions.conf +# We need to replace the "someBuildFolder" with the "device designation path" +# 031478493a016b31d6fa86dbcd4a95d114e307a7cadc46b4ab5fe8e232256229 someLocationOnDevice/Instructions/Instructions.conf + +sed -i "s+ .*$SRC_SETTINGS_LOCAL+ $DST_SETTINGS_ON_DEVICE/+g" "$DST_SETTINGS_CRC" + if [ $? -eq 0 ]; then echo "" exit 0