-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
77 lines (64 loc) · 1.71 KB
/
init.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Entry-point script for dock initialization. Simply includes the `lib/dock.sh`
# library and calls the master initialization function.
# @author Ryan Sandor Richards
export DOCK_INIT_BASE=/opt/runnable/dock-init
export HOST_IP=$(hostname -i)
source "${DOCK_INIT_BASE}/lib/util/log.sh"
if [ -z "${CONSUL_PORT+x}" ]; then
export CONSUL_PORT=8500
else
export CONSUL_PORT
fi
if [ -z "${CONSUL_HOSTNAME+x}" ]; then
log::fatal "CONSUL_HOSTNAME is not defined"
exit 1
else
export CONSUL_HOSTNAME
fi
if [ -z "${VAULT_PORT+x}" ]; then
export VAULT_PORT=8200
else
export VAULT_PORT
fi
if [ -z "${VAULT_HOSTNAME+x}" ]; then
export VAULT_HOSTNAME=$CONSUL_HOSTNAME
else
export VAULT_HOSTNAME
fi
if [ -z "${USER_VAULT_PORT+x}" ]; then
export USER_VAULT_PORT=8200
else
export USER_VAULT_PORT
fi
if [ -z "${USER_VAULT_HOSTNAME+x}" ]; then
export USER_VAULT_HOSTNAME=$USER_VAULT_HOSTNAME
else
export USER_VAULT_HOSTNAME
fi
export DOCKER_NETWORK=172.17.0.0/16
source "${DOCK_INIT_BASE}/lib/consul.sh"
source "${DOCK_INIT_BASE}/lib/aws.sh"
source "${DOCK_INIT_BASE}/lib/dock.sh"
source "${DOCK_INIT_BASE}/lib/vault.sh"
source "${DOCK_INIT_BASE}/lib/container.sh"
source "${DOCK_INIT_BASE}/lib/iptables.sh"
source "${DOCK_INIT_BASE}/lib/cleanup.sh"
# Initializes the dock
main() {
# Make sure to setup the exit trap first so we never have a dock with creds hanging about
cleanup::set_exit_trap
consul::connect
consul::get_environment
consul::configure_consul_template
dock::generate_certs
aws::get_org_ids
dock::set_hostname
dock::set_config_org
vault::store_private_registry_token
container::start
# rules must be run after docker has started
iptables::run_rules
log::info "Init Done!"
}
main