Add handling for opkg-commands

This commit is contained in:
Gerhard Hoffmann 2023-05-25 16:20:18 +02:00
parent 7db36e8de4
commit 12d1458bcb

View File

@ -3,34 +3,44 @@
# echo "CURR-HEAD=$2" # echo "CURR-HEAD=$2"
# echo "BRANCH-CHECKOUT=$3" # echo "BRANCH-CHECKOUT=$3"
readonly ch_file="/opt/app/tools/atbupdate/checkout_history" readonly CHECKOUT_HISTORY_FILE="/opt/app/tools/atbupdate/checkout_history"
readonly update_log_file="/opt/app/tools/atbupdate/update_log.csv" readonly GIT_UPDATE_LOG="/opt/app/tools/atbupdate/update_log.csv"
readonly OPKG_COMMANDS_FILE="/etc/psa_update/opkg_commands"
if [ -f $ch_file ]; then if [ -f $CHECKOUT_HISTORY_FILE ]; then
# repo: customer_281 # repo: customer_281
readonly repo=$(basename $(git rev-parse --show-toplevel)) readonly repo=$(basename $(git rev-parse --show-toplevel))
# branch: customer_281:HEAD->zg1/zone1,origin/zg1/zone1 # branch: customer_281:HEAD->zg1/zone1,origin/zg1/zone1
readonly branch=$(git log --graph --all --decorate $2 | head -n 1 | sed -E -e 's/(.*?)\((.*)\)/\2/g' | sed -E -e s/[[:space:]]//g) readonly branch=$(git log --graph --all --decorate $2 | head -n 1 | sed -E -e 's/(.*?)\((.*)\)/\2/g' | sed -E -e s/[[:space:]]//g)
readonly line="$repo:$branch" readonly line="$repo:$branch"
readonly now="$(date +%Y-%m-%dT%T)" readonly now="$(date +%Y-%m-%dT%T)"
if ! grep -Eq "$line" $ch_file; then if ! grep -Eq "$line" $CHECKOUT_HISTORY_FILE; then
# line not found. first checkout of this branch (on this PSA). # line not found. first checkout of this branch (on this PSA).
# mark dc and print-templates to be downloaded by update-tool. # mark dc and print-templates to be downloaded by update-tool.
# mark opkg_commdands-file to be executed by update-tool. echo $line >> $CHECKOUT_HISTORY_FILE
echo $line >> $ch_file echo "DOWNLOAD, /etc/dc/dc2c.4.21.bin, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/dc/dc2c.4.21.bin, $now, N/A" >> $update_log_file echo "DOWNLOAD, /etc/psa_config/DC2C_print01.json, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/psa_config/DC2C_print01.json, $now, N/A" >> $update_log_file echo "DOWNLOAD, /etc/psa_config/DC2C_print02.json, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/psa_config/DC2C_print02.json, $now, N/A" >> $update_log_file echo "DOWNLOAD, /etc/psa_config/DC2C_print03.json, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/psa_config/DC2C_print03.json, $now, N/A" >> $update_log_file echo "DOWNLOAD, /etc/psa_config/DC2C_print04.json, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/psa_config/DC2C_print04.json, $now, N/A" >> $update_log_file echo "DOWNLOAD, /etc/psa_config/DC2C_print29.json, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/psa_config/DC2C_print29.json, $now, N/A" >> $update_log_file echo "DOWNLOAD, /etc/psa_config/DC2C_print32.json, $now, N/A" >> $GIT_UPDATE_LOG
echo "DOWNLOAD, /etc/psa_config/DC2C_print32.json, $now, N/A" >> $update_log_file if [ $(wc -l < "$OPKG_COMMANDS_FILE") -gt 0 ]; then
echo "EXECUTE, /etc/psa_update/opkg_commands, $now, N/A" >> $update_log_file # file not empty
# mark opkg_commdands to be executed by update-tool.
readarray opkg_commands < <(cat $OPKG_COMMANDS_FILE)
for opkg_c in "${opkg_commands[@]}"; do
test -z $opkg_c && continue;
test ! -z $(grep -E "^\s*[#]+.*$" <<< $opkg_c) && continue
echo -n "EXECUTE, $opkg_c, $__date, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1
echo "" >> $GIT_UPDATE_LOG 2>&1
done
fi
else else
echo "Found existing line: $line. Do nothing" echo "Found existing line: $line. Do nothing"
fi fi
else else
echo "*******************************************************" echo "*******************************************************"
echo " $ch_file DOES NOT EXIST !!! " echo " $CHECKOUT_HISTORY_FILE DOES NOT EXIST !!! "
echo "*******************************************************" echo "*******************************************************"
fi fi