#!/bin/sh ########################################################################### # # Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file generate_config_files_sha.sh # # @author (last) Vy # @date (last) 25-Jul-2023 # @author (original) Vy # @date (original) 25-Jul-2023 # ############################################################################ # $1 - the path to the settings folder, locally # $2 - The path of where conf files live on the device # NOTE: The expectation is the configuration files are in a parent folder settings # eg. $HOME/project/application/resources/settings/ 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 # 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" 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 else echo "Generation of SHA file failed." exit 1002 fi