#!/bin/bash set -euo pipefail if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then cat < searches every bucket and the old store get / reads that bucket only get -h|--help Fails, naming both, if is in two places, and says so if this machine isn't one of the bucket's readers. EOF exit 0 fi this_dir="$(cd "$(dirname "$0")" && pwd)" source "${this_dir}/common.sh" if [[ "$#" -lt 1 ]]; then >&2 echo "ERROR: Need secret name" exit 1 fi name="$1" file="$(find_secret "${name}")" || exit 1 if [[ -n "${store}" && "$(dirname "${file}")" == "${store}" ]]; then # A machine that has moved to its own identity is not asked for the old key. if [[ -r "${identity}" && ! -r "${private_key}" ]]; then die "${name} is in the old store, and the old key is no longer on this machine" fi ensure_private_key else dir="$(dirname "${file}")" if ! is_reader "${dir}"; then die "$(basename "${file}" .age) is in bucket $(bucket_label "${dir}"); this machine isn't one of its readers" fi fi decrypt "${file}"