Compare commits

..

2 commits

View file

@ -89,6 +89,7 @@ function rebuild_status_file() {
[[ -z "$REBUILD_STATUS_FILE" ]] && \
REBUILD_STATUS_FILE="$REBUILD_DATA_DIR/status.json"
[[ -e "$REBUILD_STATUS_FILE" ]] || echo '{}' > "$REBUILD_STATUS_FILE"
echo "$REBUILD_STATUS_FILE"
}
function rebuild_status() {
@ -98,7 +99,7 @@ function rebuild_status() {
declare -g "$output_var=$( cat "$REBUILD_STATUS_FILE" )"
else
declare -g "$output_var=$(
jq -r --arg container "$2" '.[$container]' < "$REBUILD_STATUS_FILE"
jq -r --arg container "$1" '.[$container]' < "$REBUILD_STATUS_FILE"
)"
fi
}
@ -114,17 +115,17 @@ function update_rebuild_status() {
'del(.[$container])' <<< "$DATA"
)
else
local args=( --arg container "$1" ) arg name value exp=( )
local args=( --arg container "$1" ) arg name value expr=( )
for arg in "${@:2}"; do
name=$( head -n 1 <<< "$arg" | cut -d'=' -f1 )
name=$( cut -d'=' -f1 <<< "$arg" )
# shellcheck disable=SC2001
value=$( sed "s/$name=//" <<< "$arg" )
value=$( sed 's/[^=]\+=//' <<< "$arg" )
args+=( --arg "$name" "$value" )
exp+=( ".[\$container].${name}=\$${name}" )
expr+=( ".[\$container].$name=\$$name" )
done
rebuild_status DATA
data=$(
jq "${args[@]}" "$( implode ' | ' "${exp[@]}" )" <<< "$DATA"
jq "${args[@]}" "$( implode ' | ' "${expr[@]}" )" <<< "$DATA"
)
fi
cat <<< "$data" > "$REBUILD_STATUS_FILE"
@ -493,10 +494,10 @@ if [[ $REBUILD -eq 1 ]]; then
REBUILT_CONTAINERS=()
for container in "${!UPGRADABLE_CONTAINERS[@]}"; do
need_rebuild=0
rebuild_status CONTAINER_DATA "$container"
rebuild_status "$container" CONTAINER_DATA
# shellcheck disable=SC2153
if [[ "$CONTAINER_DATA" != "null" ]]; then
debug "$container: data='$CONTAINER_DATA'"
debug "$container: data=$CONTAINER_DATA"
trigger_date=$( jq -r .trigger_date <<< "$CONTAINER_DATA" )
start_date=$( jq -r .start_date <<< "$CONTAINER_DATA" )
end_date=$( jq -r .end_date <<< "$CONTAINER_DATA" )