File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Function to decrypt secrets
4+ decrypt_secret () {
5+ gpg --pinentry-mode loopback --passphrase " $1 " -d " $2 " 2> /dev/null
6+ }
7+
8+ # Prompt for PASS value
9+ read -sp " Enter the PASS value: " PASS
10+ echo
11+
12+ # Set up environment variables
13+ export GPG_TTY=$( tty)
14+
15+ # Decrypt secrets
16+ NATS_PASSWORD=$( decrypt_secret " $PASS " ~ /.password-store/apex-nats-password.gpg)
17+ CONSUL_PASSWORD=$( decrypt_secret " $PASS " ~ /.password-store/apex-consul-password.gpg)
18+ CONSUL_TOKEN=$( decrypt_secret " $PASS " ~ /.password-store/apex-consul-token.gpg)
19+ BADGER_PASSWORD=$( decrypt_secret " $PASS " ~ /.password-store/mpcium-badger-password.gpg)
20+
21+ # Prompt for command
22+ read -p " Enter the command to execute: " user_command
23+
24+ # Execute the command with environment variables
25+ env NATS_PASSWORD=" $NATS_PASSWORD " \
26+ CONSUL_PASSWORD=" $CONSUL_PASSWORD " \
27+ CONSUL_TOKEN=" $CONSUL_TOKEN " \
28+ BADGER_PASSWORD=" $BADGER_PASSWORD " \
29+ ENVIRONMENT=production \
30+ $user_command
31+
32+ # Clear sensitive variables
33+ unset PASS NATS_PASSWORD CONSUL_PASSWORD CONSUL_TOKEN BADGER_PASSWORD
You can’t perform that action at this time.
0 commit comments