mirror of
https://github.com/getbible/v2_builder.git
synced 2024-06-04 22:50:48 +00:00
Formated the hash code with my IDE.
This commit is contained in:
parent
a53aac8f37
commit
1a03831b50
|
@ -1,14 +1,19 @@
|
|||
#! /bin/bash
|
||||
|
||||
# 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 sha1sum >/dev/null 2>&1 || { echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."; exit 1; }
|
||||
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 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
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo >&2 "Target folder must be supplied. Aborting."
|
||||
exit 1;
|
||||
if [ $# -eq 0 ]; then
|
||||
echo >&2 "Target folder must be supplied. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# target folder
|
||||
|
@ -17,116 +22,106 @@ target_folder="$1"
|
|||
counter=0
|
||||
|
||||
# check if the folder exist
|
||||
if [ ! -d $target_folder ]
|
||||
then
|
||||
echo >&2 "Folder $target_folder not found. Aborting.";
|
||||
exit 1;
|
||||
if [ ! -d $target_folder ]; then
|
||||
echo >&2 "Folder $target_folder not found. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for filename in $target_folder/*.json; do
|
||||
# setup: positional arguments to pass in literal variables, query with code
|
||||
jq_args=( )
|
||||
# setup: positional arguments to pass in literal variables, query with code
|
||||
jq_args=()
|
||||
jq_query='.'
|
||||
jq_t_args=( )
|
||||
jq_t_args=()
|
||||
jq_t_query='.'
|
||||
# get the abbreviation
|
||||
abbreviation="${filename/.json/}"
|
||||
abbreviation="${abbreviation/${target_folder}\//}"
|
||||
# do not work with the translations or checksum file
|
||||
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]
|
||||
then
|
||||
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]; then
|
||||
continue
|
||||
fi
|
||||
# do not work with the books or chapters file
|
||||
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]
|
||||
then
|
||||
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]; then
|
||||
continue
|
||||
fi
|
||||
# make sure the book directory is build
|
||||
if [ -d "${target_folder}/$abbreviation" ]
|
||||
then
|
||||
if [ -d "${target_folder}/$abbreviation" ]; then
|
||||
# load the translation in
|
||||
bible=$( cat "${filename}" | jq '.' -a )
|
||||
bible=$(cat "${filename}" | jq '.' -a)
|
||||
# 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
|
||||
bible=$( echo "${bible}" | jq '. | del(.books) | del(.discription)' -a )
|
||||
bible=$(echo "${bible}" | jq '. | del(.books) | del(.discription)' -a)
|
||||
# set language
|
||||
language=$( echo "${bible}" | jq '.language' -r )
|
||||
language=$(echo "${bible}" | jq '.language' -r)
|
||||
# set translation
|
||||
translation=$( echo "${bible}" | jq '.translation' -r )
|
||||
translation=$(echo "${bible}" | jq '.translation' -r)
|
||||
# set direction
|
||||
direction=$( echo "${bible}" | jq '.direction' -r )
|
||||
direction=$(echo "${bible}" | jq '.direction' -r)
|
||||
# start bucket
|
||||
booksBucket="# language translation abbreviation direction name filename sha\n"
|
||||
# checksum
|
||||
checksumBucket="# filename sha\n"
|
||||
# add more
|
||||
next=$(($counter+15))
|
||||
next=$((counter + 12))
|
||||
# make sure next is not above 99
|
||||
if (("$next" > 99))
|
||||
then
|
||||
if (("$next" > 99)); then
|
||||
next=99
|
||||
fi
|
||||
counter_inner=$counter
|
||||
# read book names
|
||||
for nr in "${booknr[@]}";
|
||||
do
|
||||
for nr in "${booknr[@]}"; do
|
||||
# check if file is set
|
||||
if [ -f "${target_folder}/${abbreviation}/${nr}.json" ]
|
||||
then
|
||||
if [ -f "${target_folder}/${abbreviation}/${nr}.json" ]; then
|
||||
# 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
|
||||
echo "${book}" > "${target_folder}/${abbreviation}/${nr}.json"
|
||||
echo "${book}" >"${target_folder}/${abbreviation}/${nr}.json"
|
||||
# get the hash
|
||||
fileHash=$(sha1sum "${target_folder}/${abbreviation}/${nr}.json" | awk '{print $1}')
|
||||
# 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
|
||||
jq_t_args+=( --arg "key$nr" "$nr" )
|
||||
jq_t_args+=( --argjson "value$nr" "$book" )
|
||||
jq_t_args+=(--arg "key$nr" "$nr")
|
||||
jq_t_args+=(--argjson "value$nr" "$book")
|
||||
# build query for jq
|
||||
jq_t_query+=" | .[\$key${nr}]=\$value${nr}"
|
||||
# create/update the Bible file checksum
|
||||
echo "${fileHash}" > "${target_folder}/${abbreviation}/${nr}.sha"
|
||||
echo "${fileHash}" >"${target_folder}/${abbreviation}/${nr}.sha"
|
||||
# load book name
|
||||
book_name=$( echo "${book}" | jq '.name' -r )
|
||||
book_name=$(echo "${book}" | jq '.name' -r)
|
||||
# load the buckets
|
||||
checksumBucket+="${nr} ${nr} ${fileHash}\n"
|
||||
booksBucket+="${nr} ${language} ${translation} ${abbreviation} ${direction} ${book_name} ${nr} ${fileHash}\n"
|
||||
# load the values for json
|
||||
jq_args+=( --arg "key$nr" "${nr}" )
|
||||
jq_args+=( --arg "value$nr" "$fileHash" )
|
||||
jq_args+=(--arg "key$nr" "${nr}")
|
||||
jq_args+=(--arg "value$nr" "$fileHash")
|
||||
# build query for jq
|
||||
jq_query+=" | .[\$key${nr}]=\$value${nr}"
|
||||
# check if we have counter upto next
|
||||
if (("$counter_inner" >= "$next"))
|
||||
then
|
||||
if (("$counter_inner" >= "$next")); then
|
||||
counter_inner=$counter
|
||||
fi
|
||||
# increment the counter
|
||||
counter_inner=$((counter_inner+1))
|
||||
counter_inner=$((counter_inner + 1))
|
||||
# give notice
|
||||
echo -e "XXX\n${counter_inner}\nHashing ${abbreviation}/${nr}.json\nXXX"
|
||||
fi
|
||||
done
|
||||
# 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
|
||||
echo -e "$booksBucket" > "${target_folder}/${abbreviation}/books"
|
||||
echo -e "$booksBucket" >"${target_folder}/${abbreviation}/books"
|
||||
# run the generated command with jq
|
||||
jq "${jq_args[@]}" "$jq_query" <<<'{}' > "${target_folder}/${abbreviation}/checksum.json"
|
||||
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' > "${target_folder}/${abbreviation}/books.json"
|
||||
jq "${jq_args[@]}" "$jq_query" <<<'{}' >"${target_folder}/${abbreviation}/checksum.json"
|
||||
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' >"${target_folder}/${abbreviation}/books.json"
|
||||
# check if we have counter upto 98
|
||||
if (("$counter" >= 98))
|
||||
then
|
||||
if (("$counter" >= 98)); then
|
||||
counter=70
|
||||
fi
|
||||
# add more
|
||||
counter=$((counter+1))
|
||||
counter=$((counter + 1))
|
||||
# give notice
|
||||
echo -e "XXX\n${counter}\nDone Hashing $abbreviation books\nXXX"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
#! /bin/bash
|
||||
|
||||
# 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 sha1sum >/dev/null 2>&1 || { echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."; exit 1; }
|
||||
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 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
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo >&2 "Target folder must be supplied. Aborting."
|
||||
exit 1;
|
||||
if [ $# -eq 0 ]; then
|
||||
echo >&2 "Target folder must be supplied. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# target folder
|
||||
|
@ -17,10 +22,9 @@ target_folder="$1"
|
|||
counter=0
|
||||
|
||||
# check if the folder exist
|
||||
if [ ! -d $target_folder ]
|
||||
then
|
||||
echo >&2 "Folder $target_folder not found. Aborting.";
|
||||
exit 1;
|
||||
if [ ! -d $target_folder ]; then
|
||||
echo >&2 "Folder $target_folder not found. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for filename in $target_folder/*.json; do
|
||||
|
@ -29,107 +33,96 @@ for filename in $target_folder/*.json; do
|
|||
abbreviation="${abbreviation/${target_folder}\//}"
|
||||
echo "$abbreviation"
|
||||
# do not work with the translations or checksum file
|
||||
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]
|
||||
then
|
||||
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]; then
|
||||
continue
|
||||
fi
|
||||
# do not work with the books or chapters file
|
||||
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]
|
||||
then
|
||||
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]; then
|
||||
continue
|
||||
fi
|
||||
# make sure the book directory is build
|
||||
if [ -d "${target_folder}/$abbreviation" ]
|
||||
then
|
||||
if [ -d "${target_folder}/$abbreviation" ]; then
|
||||
# set language
|
||||
language=$( cat "${filename}" | jq '.language' -r )
|
||||
language=$(cat "${filename}" | jq '.language' -r)
|
||||
# set translation
|
||||
translation=$( cat "${filename}"| jq '.translation' -r )
|
||||
translation=$(cat "${filename}" | jq '.translation' -r)
|
||||
# set language
|
||||
direction=$( cat "${filename}" | jq '.direction' -r )
|
||||
direction=$(cat "${filename}" | jq '.direction' -r)
|
||||
# get booknumbers
|
||||
readarray -t booknr < <( cat "${filename}" | jq -r '.books[].nr')
|
||||
readarray -t booknr < <(cat "${filename}" | jq -r '.books[].nr')
|
||||
# add more
|
||||
next=$(($counter+15))
|
||||
next=$((counter + 12))
|
||||
# make sure next is not above 99
|
||||
if (("$next" > 99))
|
||||
then
|
||||
if (("$next" > 99)); then
|
||||
next=99
|
||||
fi
|
||||
counter_inner=$counter
|
||||
# read book names
|
||||
for nr in "${booknr[@]}";
|
||||
do
|
||||
# setup: positional arguments to pass in literal variables, query with code
|
||||
jq_args=( )
|
||||
for nr in "${booknr[@]}"; do
|
||||
# setup: positional arguments to pass in literal variables, query with code
|
||||
jq_args=()
|
||||
jq_query='.'
|
||||
jq_t_args=( )
|
||||
jq_t_args=()
|
||||
jq_t_query='.'
|
||||
# check if file is set
|
||||
if [ -f "${target_folder}/${abbreviation}/${nr}.json" ]
|
||||
then
|
||||
if [ -f "${target_folder}/${abbreviation}/${nr}.json" ]; then
|
||||
# chapters details
|
||||
chaptersBucket="# language translation abbreviation textdirection book_nr book_name filename sha\n"
|
||||
# checksum
|
||||
checksumBucket="# filename sha\n"
|
||||
# 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
|
||||
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
|
||||
for chapter in "${chapters[@]}";
|
||||
do
|
||||
for chapter in "${chapters[@]}"; do
|
||||
# only build hash chapter for existing files
|
||||
if [ -f "${target_folder}/${abbreviation}/${nr}/${chapter}.json" ]
|
||||
then
|
||||
if [ -f "${target_folder}/${abbreviation}/${nr}/${chapter}.json" ]; then
|
||||
# get the hash
|
||||
fileHash=$(sha1sum "${target_folder}/${abbreviation}/${nr}/${chapter}.json" | awk '{print $1}')
|
||||
# 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
|
||||
jq_t_args+=( --arg "key$chapter" "${chapter}" )
|
||||
jq_t_args+=( --argjson "value$chapter" "${chapter_info}" )
|
||||
jq_t_args+=(--arg "key$chapter" "${chapter}")
|
||||
jq_t_args+=(--argjson "value$chapter" "${chapter_info}")
|
||||
# build query for jq
|
||||
jq_t_query+=" | .[\$key${chapter}]=\$value${chapter}"
|
||||
# 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
|
||||
checksumBucket+="${chapter} ${chapter} ${fileHash}\n"
|
||||
chaptersBucket+="${chapter} ${language} ${translation} ${abbreviation} ${direction} ${nr} ${book_name} ${chapter} ${fileHash}\n"
|
||||
# load the values for json
|
||||
jq_args+=( --arg "key$chapter" "${chapter}" )
|
||||
jq_args+=( --arg "value$chapter" "$fileHash" )
|
||||
jq_args+=(--arg "key$chapter" "${chapter}")
|
||||
jq_args+=(--arg "value$chapter" "$fileHash")
|
||||
# build query for jq
|
||||
jq_query+=" | .[\$key${chapter}]=\$value${chapter}"
|
||||
# check if we have counter upto next
|
||||
if (("$counter_inner" >= "$next"))
|
||||
then
|
||||
if (("$counter_inner" >= "$next")); then
|
||||
counter_inner=$counter
|
||||
fi
|
||||
# increment the counter
|
||||
counter_inner=$((counter_inner+1))
|
||||
counter_inner=$((counter_inner + 1))
|
||||
# give notice
|
||||
echo -e "XXX\n${counter_inner}\nHashing ${abbreviation}/${nr}/${chapter}.json\nXXX"
|
||||
fi
|
||||
done
|
||||
# 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
|
||||
echo -e "$chaptersBucket" > "${target_folder}/${abbreviation}/${nr}/chapters"
|
||||
echo -e "$chaptersBucket" >"${target_folder}/${abbreviation}/${nr}/chapters"
|
||||
# run the generated command with jq
|
||||
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_args[@]}" "$jq_query" <<<'{}' >"${target_folder}/${abbreviation}/${nr}/checksum.json"
|
||||
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' >"${target_folder}/${abbreviation}/${nr}/chapters.json"
|
||||
fi
|
||||
done
|
||||
# check if we have counter upto 98
|
||||
if (("$counter" >= 98))
|
||||
then
|
||||
if (("$counter" >= 98)); then
|
||||
counter=70
|
||||
fi
|
||||
# add more
|
||||
counter=$((counter+1))
|
||||
counter=$((counter + 1))
|
||||
# give notice
|
||||
echo -e "XXX\n${counter}\nDone Hashing $abbreviation chapters\nXXX"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
#! /bin/bash
|
||||
|
||||
# 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 sha1sum >/dev/null 2>&1 || { echo >&2 "We require sha1sum for this script to run, but it's not installed. Aborting."; exit 1; }
|
||||
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 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
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo >&2 "Target folder must be supplied. Aborting."
|
||||
exit 1;
|
||||
if [ $# -eq 0 ]; then
|
||||
echo >&2 "Target folder must be supplied. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# setup: positional arguments to pass in literal variables, query with code
|
||||
jq_args=( )
|
||||
# setup: positional arguments to pass in literal variables, query with code
|
||||
jq_args=()
|
||||
jq_query='.'
|
||||
jq_t_args=( )
|
||||
jq_t_args=()
|
||||
jq_t_query='.'
|
||||
|
||||
# counter
|
||||
|
@ -26,76 +31,70 @@ target_folder="$1"
|
|||
counter=0
|
||||
|
||||
# check if the folder exist
|
||||
if [ ! -d $target_folder ]
|
||||
then
|
||||
echo >&2 "Folder $target_folder not found. Aborting.";
|
||||
exit 1;
|
||||
if [ ! -d $target_folder ]; then
|
||||
echo >&2 "Folder $target_folder not found. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# book names
|
||||
echo "# language translation abbreviation direction filename sha" > "${target_folder}/translations"
|
||||
echo "# language translation abbreviation direction filename sha" >"${target_folder}/translations"
|
||||
# checksum
|
||||
echo "# filename sha" > "${target_folder}/checksum"
|
||||
|
||||
echo "# filename sha" >"${target_folder}/checksum"
|
||||
|
||||
for filename in $target_folder/*.json; do
|
||||
# get the abbreviation
|
||||
abbreviation="${filename/.json/}"
|
||||
abbreviation="${abbreviation/${target_folder}\//}"
|
||||
# do not work with the translations or checksum file
|
||||
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]
|
||||
then
|
||||
if [[ "$abbreviation" == 'translations' || "$abbreviation" == 'checksum' ]]; then
|
||||
continue
|
||||
fi
|
||||
# do not work with the books or chapters file
|
||||
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]
|
||||
then
|
||||
if [[ "$abbreviation" == 'books' || "$abbreviation" == 'chapters' ]]; then
|
||||
continue
|
||||
fi
|
||||
# load the translation in
|
||||
bible=$( cat "${filename}" | jq '.' -a )
|
||||
bible=$(cat "${filename}" | jq '.' -a)
|
||||
# update the file formating
|
||||
echo "${bible}" > "${filename}"
|
||||
echo "${bible}" >"${filename}"
|
||||
# build the hash file name
|
||||
hashFileName="${target_folder}/${abbreviation}.sha"
|
||||
# get the hash
|
||||
fileHash=$(sha1sum "${filename}" | awk '{print $1}')
|
||||
# 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
|
||||
language=$( echo "${bible}" | jq '.language' -r )
|
||||
translation=$( echo "${bible}" | jq '.translation' -r )
|
||||
direction=$( echo "${bible}" | jq '.direction' -r )
|
||||
language=$(echo "${bible}" | jq '.language' -r)
|
||||
translation=$(echo "${bible}" | jq '.translation' -r)
|
||||
direction=$(echo "${bible}" | jq '.direction' -r)
|
||||
# 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
|
||||
jq_t_args+=( --arg "key$nr" "$abbreviation" )
|
||||
jq_t_args+=( --argjson "value$nr" "$bible" )
|
||||
jq_t_args+=(--arg "key$nr" "$abbreviation")
|
||||
jq_t_args+=(--argjson "value$nr" "$bible")
|
||||
# build query for jq
|
||||
jq_t_query+=" | .[\$key${nr}]=\$value${nr}"
|
||||
# create/update the Bible file checksum
|
||||
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
|
||||
jq_args+=( --arg "key$nr" "$abbreviation" )
|
||||
jq_args+=( --arg "value$nr" "$fileHash" )
|
||||
jq_args+=(--arg "key$nr" "$abbreviation")
|
||||
jq_args+=(--arg "value$nr" "$fileHash")
|
||||
# build query for jq
|
||||
jq_query+=" | .[\$key${nr}]=\$value${nr}"
|
||||
#next
|
||||
nr=$((nr+1))
|
||||
nr=$((nr + 1))
|
||||
# check if we have counter upto 98
|
||||
if (("$counter" >= 98))
|
||||
then
|
||||
if (("$counter" >= 98)); then
|
||||
counter=70
|
||||
fi
|
||||
# add more
|
||||
counter=$((counter+1))
|
||||
counter=$((counter + 1))
|
||||
# give notice
|
||||
echo -e "XXX\n${counter}\nDone Hashing $abbreviation\nXXX"
|
||||
done
|
||||
|
||||
# run the generated command with jq
|
||||
jq "${jq_args[@]}" "$jq_query" <<<'{}' > "${target_folder}/checksum.json"
|
||||
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' > "${target_folder}/translations.json"
|
||||
|
||||
jq "${jq_args[@]}" "$jq_query" <<<'{}' >"${target_folder}/checksum.json"
|
||||
jq "${jq_t_args[@]}" "$jq_t_query" <<<'{}' >"${target_folder}/translations.json"
|
||||
|
|
Loading…
Reference in New Issue
Block a user