4
2
mirror of https://github.com/getbible/v2_builder.git synced 2024-05-31 21:00:48 +00:00

Formated the hash code with my IDE.

This commit is contained in:
Robot 2021-04-21 02:41:43 +00:00
parent a53aac8f37
commit 1a03831b50
No known key found for this signature in database
GPG Key ID: 5A920ED2DA4160A2
3 changed files with 132 additions and 145 deletions

View File

@ -1,14 +1,19 @@
#! /bin/bash #! /bin/bash
# Do some prep work # Do some prep work
command -v jq >/dev/null 2>&1 || { echo >&2 "We require jq for this script to run, but it's not installed. Aborting."; exit 1; } command -v jq >/dev/null 2>&1 || {
command -v sha1sum >/dev/null 2>&1 || { echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."; exit 1; } echo >&2 "We require jq for this script to run, but it's not installed. Aborting."
exit 1
}
command -v sha1sum >/dev/null 2>&1 || {
echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."
exit 1
}
# make sure we have at least one argument # make sure we have at least one argument
if [ $# -eq 0 ] if [ $# -eq 0 ]; then
then echo >&2 "Target folder must be supplied. Aborting."
echo >&2 "Target folder must be supplied. Aborting." exit 1
exit 1;
fi fi
# target folder # target folder
@ -17,116 +22,106 @@ target_folder="$1"
counter=0 counter=0
# check if the folder exist # check if the folder exist
if [ ! -d $target_folder ] if [ ! -d $target_folder ]; then
then echo >&2 "Folder $target_folder not found. Aborting."
echo >&2 "Folder $target_folder not found. Aborting."; exit 1
exit 1;
fi fi
for filename in $target_folder/*.json; do for filename in $target_folder/*.json; do
# setup: positional arguments to pass in literal variables, query with code # setup: positional arguments to pass in literal variables, query with code
jq_args=( ) jq_args=()
jq_query='.' jq_query='.'
jq_t_args=( ) jq_t_args=()
jq_t_query='.' jq_t_query='.'
# get the abbreviation # get the abbreviation
abbreviation="${filename/.json/}" abbreviation="${filename/.json/}"
abbreviation="${abbreviation/${target_folder}\//}" abbreviation="${abbreviation/${target_folder}\//}"
# do not work with the translations or checksum file # do not work with the translations or checksum file
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]] if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]; then
then
continue continue
fi fi
# do not work with the books or chapters file # do not work with the books or chapters file
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]] if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]; then
then
continue continue
fi fi
# make sure the book directory is build # make sure the book directory is build
if [ -d "${target_folder}/$abbreviation" ] if [ -d "${target_folder}/$abbreviation" ]; then
then
# load the translation in # load the translation in
bible=$( cat "${filename}" | jq '.' -a ) bible=$(cat "${filename}" | jq '.' -a)
# get book numbers # get book numbers
readarray -t booknr < <( echo "${bible}" | jq -r '.books[].nr') readarray -t booknr < <(echo "${bible}" | jq -r '.books[].nr')
# now remove all books # now remove all books
bible=$( echo "${bible}" | jq '. | del(.books) | del(.discription)' -a ) bible=$(echo "${bible}" | jq '. | del(.books) | del(.discription)' -a)
# set language # set language
language=$( echo "${bible}" | jq '.language' -r ) language=$(echo "${bible}" | jq '.language' -r)
# set translation # set translation
translation=$( echo "${bible}" | jq '.translation' -r ) translation=$(echo "${bible}" | jq '.translation' -r)
# set direction # set direction
direction=$( echo "${bible}" | jq '.direction' -r ) direction=$(echo "${bible}" | jq '.direction' -r)
# start bucket # start bucket
booksBucket="# language translation abbreviation direction name filename sha\n" booksBucket="# language translation abbreviation direction name filename sha\n"
# checksum # checksum
checksumBucket="# filename sha\n" checksumBucket="# filename sha\n"
# add more # add more
next=$(($counter+15)) next=$((counter + 12))
# make sure next is not above 99 # make sure next is not above 99
if (("$next" > 99)) if (("$next" > 99)); then
then
next=99 next=99
fi fi
counter_inner=$counter counter_inner=$counter
# read book names # read book names
for nr in "${booknr[@]}"; for nr in "${booknr[@]}"; do
do
# check if file is set # check if file is set
if [ -f "${target_folder}/${abbreviation}/${nr}.json" ] if [ -f "${target_folder}/${abbreviation}/${nr}.json" ]; then
then
# load the book in # load the book in
book=$( cat "${target_folder}/${abbreviation}/${nr}.json" | jq '.' -a ) book=$(cat "${target_folder}/${abbreviation}/${nr}.json" | jq '.' -a)
# update the file formatting # update the file formatting
echo "${book}" > "${target_folder}/${abbreviation}/${nr}.json" echo "${book}" >"${target_folder}/${abbreviation}/${nr}.json"
# get the hash # get the hash
fileHash=$(sha1sum "${target_folder}/${abbreviation}/${nr}.json" | awk '{print $1}') fileHash=$(sha1sum "${target_folder}/${abbreviation}/${nr}.json" | awk '{print $1}')
# build the return values # build the return values
book=$( echo "${book}" | jq ". | del(.chapters) | .[\"url\"]=\"https://getbible.net/v2/${abbreviation}/${nr}.json\" | .[\"sha\"]=\"${fileHash}\"" -a ) book=$(echo "${book}" | jq ". | del(.chapters) | .[\"url\"]=\"https://getbible.net/v2/${abbreviation}/${nr}.json\" | .[\"sha\"]=\"${fileHash}\"" -a)
# load the values for json # load the values for json
jq_t_args+=( --arg "key$nr" "$nr" ) jq_t_args+=(--arg "key$nr" "$nr")
jq_t_args+=( --argjson "value$nr" "$book" ) jq_t_args+=(--argjson "value$nr" "$book")
# build query for jq # build query for jq
jq_t_query+=" | .[\$key${nr}]=\$value${nr}" jq_t_query+=" | .[\$key${nr}]=\$value${nr}"
# create/update the Bible file checksum # create/update the Bible file checksum
echo "${fileHash}" > "${target_folder}/${abbreviation}/${nr}.sha" echo "${fileHash}" >"${target_folder}/${abbreviation}/${nr}.sha"
# load book name # load book name
book_name=$( echo "${book}" | jq '.name' -r ) book_name=$(echo "${book}" | jq '.name' -r)
# load the buckets # load the buckets
checksumBucket+="${nr} ${nr} ${fileHash}\n" checksumBucket+="${nr} ${nr} ${fileHash}\n"
booksBucket+="${nr} ${language} ${translation} ${abbreviation} ${direction} ${book_name} ${nr} ${fileHash}\n" booksBucket+="${nr} ${language} ${translation} ${abbreviation} ${direction} ${book_name} ${nr} ${fileHash}\n"
# load the values for json # load the values for json
jq_args+=( --arg "key$nr" "${nr}" ) jq_args+=(--arg "key$nr" "${nr}")
jq_args+=( --arg "value$nr" "$fileHash" ) jq_args+=(--arg "value$nr" "$fileHash")
# build query for jq # build query for jq
jq_query+=" | .[\$key${nr}]=\$value${nr}" jq_query+=" | .[\$key${nr}]=\$value${nr}"
# check if we have counter upto next # check if we have counter upto next
if (("$counter_inner" >= "$next")) if (("$counter_inner" >= "$next")); then
then
counter_inner=$counter counter_inner=$counter
fi fi
# increment the counter # increment the counter
counter_inner=$((counter_inner+1)) counter_inner=$((counter_inner + 1))
# give notice # give notice
echo -e "XXX\n${counter_inner}\nHashing ${abbreviation}/${nr}.json\nXXX" echo -e "XXX\n${counter_inner}\nHashing ${abbreviation}/${nr}.json\nXXX"
fi fi
done done
# set books checksum to text file # set books checksum to text file
echo -e "$checksumBucket" > "${target_folder}/${abbreviation}/checksum" echo -e "$checksumBucket" >"${target_folder}/${abbreviation}/checksum"
# set books details to text file # set books details to text file
echo -e "$booksBucket" > "${target_folder}/${abbreviation}/books" echo -e "$booksBucket" >"${target_folder}/${abbreviation}/books"
# run the generated command with jq # run the generated command with jq
jq "${jq_args[@]}" "$jq_query" <<<'{}' > "${target_folder}/${abbreviation}/checksum.json" jq "${jq_args[@]}" "$jq_query" <<<'{}' >"${target_folder}/${abbreviation}/checksum.json"
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' > "${target_folder}/${abbreviation}/books.json" jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' >"${target_folder}/${abbreviation}/books.json"
# check if we have counter upto 98 # check if we have counter upto 98
if (("$counter" >= 98)) if (("$counter" >= 98)); then
then
counter=70 counter=70
fi fi
# add more # add more
counter=$((counter+1)) counter=$((counter + 1))
# give notice # give notice
echo -e "XXX\n${counter}\nDone Hashing $abbreviation books\nXXX" echo -e "XXX\n${counter}\nDone Hashing $abbreviation books\nXXX"
fi fi
done done

View File

@ -1,14 +1,19 @@
#! /bin/bash #! /bin/bash
# Do some prep work # Do some prep work
command -v jq >/dev/null 2>&1 || { echo >&2 "We require jq for this script to run, but it's not installed. Aborting."; exit 1; } command -v jq >/dev/null 2>&1 || {
command -v sha1sum >/dev/null 2>&1 || { echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."; exit 1; } echo >&2 "We require jq for this script to run, but it's not installed. Aborting."
exit 1
}
command -v sha1sum >/dev/null 2>&1 || {
echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."
exit 1
}
# make sure we have at least one argument # make sure we have at least one argument
if [ $# -eq 0 ] if [ $# -eq 0 ]; then
then echo >&2 "Target folder must be supplied. Aborting."
echo >&2 "Target folder must be supplied. Aborting." exit 1
exit 1;
fi fi
# target folder # target folder
@ -17,10 +22,9 @@ target_folder="$1"
counter=0 counter=0
# check if the folder exist # check if the folder exist
if [ ! -d $target_folder ] if [ ! -d $target_folder ]; then
then echo >&2 "Folder $target_folder not found. Aborting."
echo >&2 "Folder $target_folder not found. Aborting."; exit 1
exit 1;
fi fi
for filename in $target_folder/*.json; do for filename in $target_folder/*.json; do
@ -29,107 +33,96 @@ for filename in $target_folder/*.json; do
abbreviation="${abbreviation/${target_folder}\//}" abbreviation="${abbreviation/${target_folder}\//}"
echo "$abbreviation" echo "$abbreviation"
# do not work with the translations or checksum file # do not work with the translations or checksum file
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]] if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]; then
then
continue continue
fi fi
# do not work with the books or chapters file # do not work with the books or chapters file
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]] if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]; then
then
continue continue
fi fi
# make sure the book directory is build # make sure the book directory is build
if [ -d "${target_folder}/$abbreviation" ] if [ -d "${target_folder}/$abbreviation" ]; then
then
# set language # set language
language=$( cat "${filename}" | jq '.language' -r ) language=$(cat "${filename}" | jq '.language' -r)
# set translation # set translation
translation=$( cat "${filename}"| jq '.translation' -r ) translation=$(cat "${filename}" | jq '.translation' -r)
# set language # set language
direction=$( cat "${filename}" | jq '.direction' -r ) direction=$(cat "${filename}" | jq '.direction' -r)
# get booknumbers # get booknumbers
readarray -t booknr < <( cat "${filename}" | jq -r '.books[].nr') readarray -t booknr < <(cat "${filename}" | jq -r '.books[].nr')
# add more # add more
next=$(($counter+15)) next=$((counter + 12))
# make sure next is not above 99 # make sure next is not above 99
if (("$next" > 99)) if (("$next" > 99)); then
then
next=99 next=99
fi fi
counter_inner=$counter counter_inner=$counter
# read book names # read book names
for nr in "${booknr[@]}"; for nr in "${booknr[@]}"; do
do # setup: positional arguments to pass in literal variables, query with code
# setup: positional arguments to pass in literal variables, query with code jq_args=()
jq_args=( )
jq_query='.' jq_query='.'
jq_t_args=( ) jq_t_args=()
jq_t_query='.' jq_t_query='.'
# check if file is set # check if file is set
if [ -f "${target_folder}/${abbreviation}/${nr}.json" ] if [ -f "${target_folder}/${abbreviation}/${nr}.json" ]; then
then
# chapters details # chapters details
chaptersBucket="# language translation abbreviation textdirection book_nr book_name filename sha\n" chaptersBucket="# language translation abbreviation textdirection book_nr book_name filename sha\n"
# checksum # checksum
checksumBucket="# filename sha\n" checksumBucket="# filename sha\n"
# get book name # get book name
book_name=$( cat "${target_folder}/${abbreviation}/${nr}.json" | jq '.name' -r ) book_name=$(cat "${target_folder}/${abbreviation}/${nr}.json" | jq '.name' -r)
# get all chapters # get all chapters
readarray -t chapters < <( cat "${target_folder}/${abbreviation}/${nr}.json" | jq -r '.chapters[].chapter' | sort -g) readarray -t chapters < <(cat "${target_folder}/${abbreviation}/${nr}.json" | jq -r '.chapters[].chapter' | sort -g)
# get chapters # get chapters
for chapter in "${chapters[@]}"; for chapter in "${chapters[@]}"; do
do
# only build hash chapter for existing files # only build hash chapter for existing files
if [ -f "${target_folder}/${abbreviation}/${nr}/${chapter}.json" ] if [ -f "${target_folder}/${abbreviation}/${nr}/${chapter}.json" ]; then
then
# get the hash # get the hash
fileHash=$(sha1sum "${target_folder}/${abbreviation}/${nr}/${chapter}.json" | awk '{print $1}') fileHash=$(sha1sum "${target_folder}/${abbreviation}/${nr}/${chapter}.json" | awk '{print $1}')
# load the book in # load the book in
chapter_info=$( cat "${target_folder}/${abbreviation}/${nr}/${chapter}.json" | jq ". | del(.verses) | .[\"url\"]=\"https://getbible.net/v2/${abbreviation}/${nr}/${chapter}.json\" | .[\"sha\"]=\"${fileHash}\"" -a ) chapter_info=$(cat "${target_folder}/${abbreviation}/${nr}/${chapter}.json" | jq ". | del(.verses) | .[\"url\"]=\"https://getbible.net/v2/${abbreviation}/${nr}/${chapter}.json\" | .[\"sha\"]=\"${fileHash}\"" -a)
# load the values for json # load the values for json
jq_t_args+=( --arg "key$chapter" "${chapter}" ) jq_t_args+=(--arg "key$chapter" "${chapter}")
jq_t_args+=( --argjson "value$chapter" "${chapter_info}" ) jq_t_args+=(--argjson "value$chapter" "${chapter_info}")
# build query for jq # build query for jq
jq_t_query+=" | .[\$key${chapter}]=\$value${chapter}" jq_t_query+=" | .[\$key${chapter}]=\$value${chapter}"
# create/update the Bible file checksum # create/update the Bible file checksum
echo "${fileHash}" > "${target_folder}/${abbreviation}/${nr}/${chapter}.sha" echo "${fileHash}" >"${target_folder}/${abbreviation}/${nr}/${chapter}.sha"
# load the buckets # load the buckets
checksumBucket+="${chapter} ${chapter} ${fileHash}\n" checksumBucket+="${chapter} ${chapter} ${fileHash}\n"
chaptersBucket+="${chapter} ${language} ${translation} ${abbreviation} ${direction} ${nr} ${book_name} ${chapter} ${fileHash}\n" chaptersBucket+="${chapter} ${language} ${translation} ${abbreviation} ${direction} ${nr} ${book_name} ${chapter} ${fileHash}\n"
# load the values for json # load the values for json
jq_args+=( --arg "key$chapter" "${chapter}" ) jq_args+=(--arg "key$chapter" "${chapter}")
jq_args+=( --arg "value$chapter" "$fileHash" ) jq_args+=(--arg "value$chapter" "$fileHash")
# build query for jq # build query for jq
jq_query+=" | .[\$key${chapter}]=\$value${chapter}" jq_query+=" | .[\$key${chapter}]=\$value${chapter}"
# check if we have counter upto next # check if we have counter upto next
if (("$counter_inner" >= "$next")) if (("$counter_inner" >= "$next")); then
then
counter_inner=$counter counter_inner=$counter
fi fi
# increment the counter # increment the counter
counter_inner=$((counter_inner+1)) counter_inner=$((counter_inner + 1))
# give notice # give notice
echo -e "XXX\n${counter_inner}\nHashing ${abbreviation}/${nr}/${chapter}.json\nXXX" echo -e "XXX\n${counter_inner}\nHashing ${abbreviation}/${nr}/${chapter}.json\nXXX"
fi fi
done done
# set books checksum to text file # set books checksum to text file
echo -e "$checksumBucket" > "${target_folder}/${abbreviation}/${nr}/checksum" echo -e "$checksumBucket" >"${target_folder}/${abbreviation}/${nr}/checksum"
# set books details to text file # set books details to text file
echo -e "$chaptersBucket" > "${target_folder}/${abbreviation}/${nr}/chapters" echo -e "$chaptersBucket" >"${target_folder}/${abbreviation}/${nr}/chapters"
# run the generated command with jq # run the generated command with jq
jq "${jq_args[@]}" "$jq_query" <<<'{}' > "${target_folder}/${abbreviation}/${nr}/checksum.json" jq "${jq_args[@]}" "$jq_query" <<<'{}' >"${target_folder}/${abbreviation}/${nr}/checksum.json"
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' > "${target_folder}/${abbreviation}/${nr}/chapters.json" jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' >"${target_folder}/${abbreviation}/${nr}/chapters.json"
fi fi
done done
# check if we have counter upto 98 # check if we have counter upto 98
if (("$counter" >= 98)) if (("$counter" >= 98)); then
then
counter=70 counter=70
fi fi
# add more # add more
counter=$((counter+1)) counter=$((counter + 1))
# give notice # give notice
echo -e "XXX\n${counter}\nDone Hashing $abbreviation chapters\nXXX" echo -e "XXX\n${counter}\nDone Hashing $abbreviation chapters\nXXX"
fi fi
done done

View File

@ -1,20 +1,25 @@
#! /bin/bash #! /bin/bash
# Do some prep work # Do some prep work
command -v jq >/dev/null 2>&1 || { echo >&2 "We require jq for this script to run, but it's not installed. Aborting."; exit 1; } command -v jq >/dev/null 2>&1 || {
command -v sha1sum >/dev/null 2>&1 || { echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."; exit 1; } echo >&2 "We require jq for this script to run, but it's not installed. Aborting."
exit 1
}
command -v sha1sum >/dev/null 2>&1 || {
echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."
exit 1
}
# make sure we have at least one argument # make sure we have at least one argument
if [ $# -eq 0 ] if [ $# -eq 0 ]; then
then echo >&2 "Target folder must be supplied. Aborting."
echo >&2 "Target folder must be supplied. Aborting." exit 1
exit 1;
fi fi
# setup: positional arguments to pass in literal variables, query with code # setup: positional arguments to pass in literal variables, query with code
jq_args=( ) jq_args=()
jq_query='.' jq_query='.'
jq_t_args=( ) jq_t_args=()
jq_t_query='.' jq_t_query='.'
# counter # counter
@ -26,76 +31,70 @@ target_folder="$1"
counter=0 counter=0
# check if the folder exist # check if the folder exist
if [ ! -d $target_folder ] if [ ! -d $target_folder ]; then
then echo >&2 "Folder $target_folder not found. Aborting."
echo >&2 "Folder $target_folder not found. Aborting."; exit 1
exit 1;
fi fi
# book names # book names
echo "# language translation abbreviation direction filename sha" > "${target_folder}/translations" echo "# language translation abbreviation direction filename sha" >"${target_folder}/translations"
# checksum # checksum
echo "# filename sha" > "${target_folder}/checksum" echo "# filename sha" >"${target_folder}/checksum"
for filename in $target_folder/*.json; do for filename in $target_folder/*.json; do
# get the abbreviation # get the abbreviation
abbreviation="${filename/.json/}" abbreviation="${filename/.json/}"
abbreviation="${abbreviation/${target_folder}\//}" abbreviation="${abbreviation/${target_folder}\//}"
# do not work with the translations or checksum file # do not work with the translations or checksum file
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]] if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]; then
then
continue continue
fi fi
# do not work with the books or chapters file # do not work with the books or chapters file
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]] if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]; then
then
continue continue
fi fi
# load the translation in # load the translation in
bible=$( cat "${filename}" | jq '.' -a ) bible=$(cat "${filename}" | jq '.' -a)
# update the file formating # update the file formating
echo "${bible}" > "${filename}" echo "${bible}" >"${filename}"
# build the hash file name # build the hash file name
hashFileName="${target_folder}/${abbreviation}.sha" hashFileName="${target_folder}/${abbreviation}.sha"
# get the hash # get the hash
fileHash=$(sha1sum "${filename}" | awk '{print $1}') fileHash=$(sha1sum "${filename}" | awk '{print $1}')
# build the return values # build the return values
bible=$( echo "${bible}" | jq ". | del(.books) | del(.discription) | .[\"url\"]=\"https://getbible.net/v2/${abbreviation}.json\" | .[\"sha\"]=\"${fileHash}\"" -a ) bible=$(echo "${bible}" | jq ". | del(.books) | del(.discription) | .[\"url\"]=\"https://getbible.net/v2/${abbreviation}.json\" | .[\"sha\"]=\"${fileHash}\"" -a)
# get the details # get the details
language=$( echo "${bible}" | jq '.language' -r ) language=$(echo "${bible}" | jq '.language' -r)
translation=$( echo "${bible}" | jq '.translation' -r ) translation=$(echo "${bible}" | jq '.translation' -r)
direction=$( echo "${bible}" | jq '.direction' -r ) direction=$(echo "${bible}" | jq '.direction' -r)
# set file details to text file # set file details to text file
echo "${nr} ${language} ${translation} ${abbreviation} ${direction} ${abbreviation} ${fileHash}" >> "${target_folder}/translations" echo "${nr} ${language} ${translation} ${abbreviation} ${direction} ${abbreviation} ${fileHash}" >>"${target_folder}/translations"
# load the values for json # load the values for json
jq_t_args+=( --arg "key$nr" "$abbreviation" ) jq_t_args+=(--arg "key$nr" "$abbreviation")
jq_t_args+=( --argjson "value$nr" "$bible" ) jq_t_args+=(--argjson "value$nr" "$bible")
# build query for jq # build query for jq
jq_t_query+=" | .[\$key${nr}]=\$value${nr}" jq_t_query+=" | .[\$key${nr}]=\$value${nr}"
# create/update the Bible file checksum # create/update the Bible file checksum
echo "${fileHash}" > "$hashFileName" echo "${fileHash}" >"$hashFileName"
# echo "${fileHash}" > "$_hashFileName" # echo "${fileHash}" > "$_hashFileName"
echo "${nr} ${abbreviation} ${fileHash}" >> "${target_folder}/checksum" echo "${nr} ${abbreviation} ${fileHash}" >>"${target_folder}/checksum"
# load the values for json # load the values for json
jq_args+=( --arg "key$nr" "$abbreviation" ) jq_args+=(--arg "key$nr" "$abbreviation")
jq_args+=( --arg "value$nr" "$fileHash" ) jq_args+=(--arg "value$nr" "$fileHash")
# build query for jq # build query for jq
jq_query+=" | .[\$key${nr}]=\$value${nr}" jq_query+=" | .[\$key${nr}]=\$value${nr}"
#next #next
nr=$((nr+1)) nr=$((nr + 1))
# check if we have counter upto 98 # check if we have counter upto 98
if (("$counter" >= 98)) if (("$counter" >= 98)); then
then
counter=70 counter=70
fi fi
# add more # add more
counter=$((counter+1)) counter=$((counter + 1))
# give notice # give notice
echo -e "XXX\n${counter}\nDone Hashing $abbreviation\nXXX" echo -e "XXX\n${counter}\nDone Hashing $abbreviation\nXXX"
done done
# run the generated command with jq # run the generated command with jq
jq "${jq_args[@]}" "$jq_query" <<<'{}' > "${target_folder}/checksum.json" jq "${jq_args[@]}" "$jq_query" <<<'{}' >"${target_folder}/checksum.json"
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' > "${target_folder}/translations.json" jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' >"${target_folder}/translations.json"