Compare commits

..

2 commits

View file

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