blob: 2675066aaae4337e21557d6bc1e303848d59ac08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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}")"
|