summaryrefslogtreecommitdiff
path: root/secrets/ensure.sh
diff options
context:
space:
mode:
Diffstat (limited to 'secrets/ensure.sh')
-rwxr-xr-xsecrets/ensure.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/secrets/ensure.sh b/secrets/ensure.sh
new file mode 100755
index 0000000..e11212f
--- /dev/null
+++ b/secrets/ensure.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then
+ cat <<EOF
+ensure: Ensure the private key is configured and available
+
+Verifies that the age private key is properly set up for secret operations.
+If not configured, prompts the user to enter it.
+
+Usage:
+ ensure
+ ensure -h|--help
+
+The command will:
+1. Check if the private key exists and is readable
+2. If not found, prompt for manual entry
+3. Validate the entered key against the public key
+4. Store the private key in the appropriate location
+
+Note: Interactive command that may prompt for user input.
+EOF
+ exit 0
+fi
+
+this_dir="$(cd "$(dirname "$0")" && pwd)"
+root_dir="$(cd "${this_dir}" && cd .. && pwd)"
+
+source "${this_dir}/common.sh"
+
+ensure_private_key