summaryrefslogtreecommitdiff
path: root/secrets/put.sh
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
committerIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
commit13cc065ec014b86369dfe4ad60d1a43fa06fd251 (patch)
tree684690c61b7b59758c2aac132c65b81c86de0608 /secrets/put.sh
dotfiles
Shell, editor and terminal configuration, the tools that go with them, and szecret, an age-based secret manager whose store lives elsewhere. History restarts here. What came before was not written to be read by anyone else, and carried machine names, addresses and an encrypted secret store; it is kept privately instead. What is left is meant to be safe on any machine, including one whose owner is not me: see CLAUDE.md for the rule it is written to.
Diffstat (limited to 'secrets/put.sh')
-rwxr-xr-xsecrets/put.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/secrets/put.sh b/secrets/put.sh
new file mode 100755
index 0000000..2675066
--- /dev/null
+++ b/secrets/put.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then
+ cat <<EOF
+put: Store a secret in the encrypted store
+
+Encrypts data from stdin and stores it as a named secret in the global store.
+
+Usage:
+ put <secret-name>
+ echo "secret-value" | put <secret-name>
+ put -h|--help
+
+Arguments:
+ secret-name Name to store the secret under
+
+The command will:
+1. Read data from stdin
+2. Encrypt the data using age with the public key
+3. Store the encrypted data in the store as <secret-name>.age
+
+Note: Will overwrite existing secrets with the same name.
+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"
+
+ensure_age
+age_encrypt "${public_key}" "$(file_for "${name}")"
+