File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -40,9 +40,12 @@ source "${DOCK_INIT_BASE}/lib/aws.sh"
40
40
source " ${DOCK_INIT_BASE} /lib/dock.sh"
41
41
source " ${DOCK_INIT_BASE} /lib/container.sh"
42
42
source " ${DOCK_INIT_BASE} /lib/iptables.sh"
43
+ source " ${DOCK_INIT_BASE} /lib/cleanup.sh"
43
44
44
45
# Initializes the dock
45
46
main () {
47
+ # Make sure to setup the exit trap first so we never have a dock with creds hanging about
48
+ cleanup::set_exit_trap
46
49
consul::connect
47
50
consul::get_environment
48
51
consul::configure_consul_template
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # An "on exit" trap to clean up sensitive keys and files on the dock itself.
4
+ # Note that this will have no effect if the `DONT_DELETE_KEYS` environment has
5
+ # been set (useful for testing)
6
+ cleanup::exit_trap () {
7
+ # Delete the keys unless the `DONT_DELETE_KEYS` flag is set
8
+ if [[ " ${DONT_DELETE_KEYS} " == " " ]]; then
9
+ log::info ' [CLEANUP TRAP] Removing Keys'
10
+ rm -f " ${CERT_PATH} " /ca-key.pem \
11
+ " ${CERT_PATH} " /pass \
12
+ " ${DOCK_INIT_BASE} " /consul-resources/template-config.hcl \
13
+ " ${DOCK_INIT_BASE} " /consul-resources/vault/** /auth-token \
14
+ " ${DOCK_INIT_BASE} " /consul-resources/vault/** /token-* \
15
+ " ${DOCK_INIT_BASE} " /key/rollbar.token
16
+ fi
17
+ }
18
+
19
+ # Sets the cleanup trap for the entire script
20
+ cleanup::set_exit_trap () {
21
+ log::info " Setting key cleanup trap"
22
+ trap ' cleanup::exit_trap' EXIT
23
+ }
You can’t perform that action at this time.
0 commit comments