Added write_log_file()

This commit is contained in:
Gerhard Hoffmann 2023-05-24 12:08:59 +02:00
parent 505911ef5b
commit c94b276be0

View File

@ -27,8 +27,9 @@ get_commit_for_blob () {
grep -q $1 && echo -n {} && head -n 1") grep -q $1 && echo -n {} && head -n 1")
} }
write_log_file () {
local __date = $(date +"%Y-%m-%dT%T")
for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
local __datum = $(date +"%Y-%m-%dT%T")
if grep -E -q "(DC.*json|dc.*hex|dc.*bin|tariff.*json)" <<< $fn; then if grep -E -q "(DC.*json|dc.*hex|dc.*bin|tariff.*json)" <<< $fn; then
# called in repository: $fn is e.g. etc/psa_tariff/tariff01.json # called in repository: $fn is e.g. etc/psa_tariff/tariff01.json
# add '/' prefix # add '/' prefix
@ -39,17 +40,20 @@ for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
# fsize=$(ls -l "$fn" | awk '{ print $5 }') # fsize=$(ls -l "$fn" | awk '{ print $5 }')
# echo "$fn $fsize $blob $commit" >> $GIT_PULL_TMP # echo "$fn $fsize $blob $commit" >> $GIT_PULL_TMP
# fi # fi
echo "DOWNLOAD, $fn, $__datum, N/A" >> "$GIT_UPDATE_LOG" echo "DOWNLOAD, $fn, $__date, N/A" >> "$GIT_UPDATE_LOG"
fi fi
if grep -E -q ".*opkg_commands" <<< $fn; then if grep -E -q ".*opkg_commands" <<< $fn; then
readarray opkg_commands < <(cat $fn) readarray opkg_commands < <(cat $fn)
for opkg_c in "${opkg_commands[@]}"; do for opkg_c in "${opkg_commands[@]}"; do
test -z $opkg_c && continue; test -z $opkg_c && continue;
test ! -z $(grep -E "^\s*[#]+.*$" <<< $opkg_c) && continue test ! -z $(grep -E "^\s*[#]+.*$" <<< $opkg_c) && continue
echo -n "EXECUTE, $opkg_c, $__datum, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1 echo -n "EXECUTE, $opkg_c, $__date, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1
echo "" >> $GIT_UPDATE_LOG 2>&1 echo "" >> $GIT_UPDATE_LOG 2>&1
done done
# source "$fn" # source "$fn"
fi fi
done done
}
write_log_file