Compare commits

..

2 commits

View file

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