#!/usr/bin/env bash

set -eou pipefail

script_dir="$(dirname "${BASH_SOURCE[0]}")"

scenario_file="$1"

while IFS= read -r line; do
    case "$line" in
        zrn_map:*)
            zrn_name="$(echo "${line#*: }" | tr -d '"')"
            ;;
        zrn_hash:*)
            zrn_hash="$(echo "${line#*: }" | tr -d '"')"
            ;;
    esac
done < "$scenario_file"

echo $zrn_name $zrn_hash

"$script_dir/remove_zrn_imagery.sh" "$zrn_name" "$zrn_hash"

new_hash="$(sha256sum "$zrn_name" | cut -f1 -d' ')"
echo $new_hash

sed -i "s/$zrn_hash/$new_hash/g" "$scenario_file"
