2023-03-27 16:10:41 +02:00
|
|
|
#!/bin/bash -
|
|
|
|
|
|
|
|
# FILE="/tmp/post-merge$(date +%FT%H-%M-%S)"
|
|
|
|
# commit=$(git rev-parse --verify HEAD)
|
|
|
|
# echo "$commit $(git cat-file commit $commit)" >> /tmp/post-merge
|
|
|
|
|
|
|
|
# Redirect output to stderr.
|
|
|
|
exec 1>&2
|
|
|
|
|
|
|
|
if [ -z $IFS ]; then
|
|
|
|
IFS=$'\n'
|
|
|
|
fi
|
|
|
|
|
2023-05-24 11:35:50 +02:00
|
|
|
GIT_UPDATE_LOG=/opt/app/tools/atbupdate/update_log.csv
|
2023-03-27 16:10:41 +02:00
|
|
|
|
2023-05-24 11:35:50 +02:00
|
|
|
#TODO: use in UpdateController
|
2023-03-27 16:10:41 +02:00
|
|
|
|
2023-04-12 15:28:39 +02:00
|
|
|
get_blob () { # get the blob of the file(name) passed as $1
|
|
|
|
# note: this can be used for any file in the filesystem
|
|
|
|
echo $(git hash-object $1)
|
|
|
|
}
|
|
|
|
|
|
|
|
get_commit_for_blob () {
|
2023-04-25 11:01:22 +02:00
|
|
|
# search for the blob in all commits for the file(name) $1
|
2023-04-25 11:41:49 +02:00
|
|
|
echo $(git log --all --pretty=format:%H -- $2 |
|
|
|
|
xargs -I{} bash -c "git ls-tree {} -- $2 |
|
|
|
|
grep -q $1 && echo -n {} && head -n 1")
|
2023-04-12 15:28:39 +02:00
|
|
|
}
|
|
|
|
|
2023-03-27 16:10:41 +02:00
|
|
|
for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
|
2023-05-24 12:06:01 +02:00
|
|
|
local __datum = $(date +"%Y-%m-%dT%T")
|
2023-03-30 12:46:04 +02:00
|
|
|
if grep -E -q "(DC.*json|dc.*hex|dc.*bin|tariff.*json)" <<< $fn; then
|
2023-04-25 10:50:10 +02:00
|
|
|
# called in repository: $fn is e.g. etc/psa_tariff/tariff01.json
|
|
|
|
# add '/' prefix
|
|
|
|
fn=$(echo $fn | awk '{ printf "/"$0 }')
|
2023-05-24 11:35:50 +02:00
|
|
|
# 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
|
2023-05-24 12:06:01 +02:00
|
|
|
echo "DOWNLOAD, $fn, $__datum, N/A" >> "$GIT_UPDATE_LOG"
|
2023-03-27 16:10:41 +02:00
|
|
|
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
|
2023-05-24 12:06:01 +02:00
|
|
|
echo -n "EXECUTE, $opkg_c, $__datum, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1
|
2023-05-24 11:35:50 +02:00
|
|
|
echo "" >> $GIT_UPDATE_LOG 2>&1
|
2023-03-27 16:10:41 +02:00
|
|
|
done
|
2023-05-24 11:35:50 +02:00
|
|
|
# source "$fn"
|
2023-03-27 16:10:41 +02:00
|
|
|
fi
|
|
|
|
done
|
2023-05-24 12:01:28 +02:00
|
|
|
|