summaryrefslogtreecommitdiff
path: root/secrets/ready.sh
blob: 2760ec4a89b70f5bde6f44f75257025de166749a (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
#!/bin/bash

set -euo pipefail

if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then
    cat <<EOF
ready: Check if the secret management system is ready for use

Ready means a store (buckets, or the old store) and an identity to read it
with: this machine's own (szecret enrol), or the old key. Exits with status 0
if ready, non-zero if not.

Usage:
  ready
  ready -h|--help

The command will:
1. Check for this machine's identity, or the old private key
2. Perform any necessary legacy key migration
3. Exit with appropriate status code

Note: Silent command, check exit status for result.
EOF
    exit 0
fi

this_dir="$(cd "$(dirname "$(realpath "$0")")" && pwd)"
szecret_quiet=1
source "${this_dir}/common.sh"

if [[ -r "${identity}" ]]; then
    exit 0
fi
[[ -n "${store}" ]] && private_key_is_setup