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,29 +27,33 @@ get_commit_for_blob () {
grep -q $1 && echo -n {} && head -n 1")
}
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
# called in repository: $fn is e.g. etc/psa_tariff/tariff01.json
# add '/' prefix
fn=$(echo $fn | awk '{ printf "/"$0 }')
# if [[ -f "$fn" ]]; then
# blob=$(get_blob "$fn")
# commit=$(get_commit_for_blob $blob "$fn")
# fsize=$(ls -l "$fn" | awk '{ print $5 }')
# echo "$fn $fsize $blob $commit" >> $GIT_PULL_TMP
# fi
echo "DOWNLOAD, $fn, $__datum, N/A" >> "$GIT_UPDATE_LOG"
fi
if grep -E -q ".*opkg_commands" <<< $fn; then
readarray opkg_commands < <(cat $fn)
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, $__datum, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1
echo "" >> $GIT_UPDATE_LOG 2>&1
done
# source "$fn"
fi
done
write_log_file () {
local __date = $(date +"%Y-%m-%dT%T")
for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
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
# add '/' prefix
fn=$(echo $fn | awk '{ printf "/"$0 }')
# if [[ -f "$fn" ]]; then
# blob=$(get_blob "$fn")
# commit=$(get_commit_for_blob $blob "$fn")
# fsize=$(ls -l "$fn" | awk '{ print $5 }')
# echo "$fn $fsize $blob $commit" >> $GIT_PULL_TMP
# fi
echo "DOWNLOAD, $fn, $__date, N/A" >> "$GIT_UPDATE_LOG"
fi
if grep -E -q ".*opkg_commands" <<< $fn; then
readarray opkg_commands < <(cat $fn)
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
# source "$fn"
fi
done
}
write_log_file