#!/bin/sh set -eu if [ "$#" -ne 1 ] || ! printf '%s\n' "$1" | grep -Eq '^[0-9a-f]{40}$'; then echo "usage: $0 " >&2 exit 2 fi script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) repository_dir=$(dirname -- "${script_dir}") kustomization="${repository_dir}/apps/immich-sync/kustomization.yaml" temporary="${kustomization}.tmp" awk -v tag="$1" ' /^ newTag: / { if (updated) { print "multiple newTag fields found" > "/dev/stderr" exit 1 } print " newTag: " tag updated = 1 next } { print } END { if (!updated) { print "newTag field not found" > "/dev/stderr" exit 1 } } ' "${kustomization}" > "${temporary}" mv "${temporary}" "${kustomization}"