-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapper.sh
68 lines (54 loc) · 1.61 KB
/
wrapper.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
#!/bin/bash
export DOCKER_HOST=tcp://0.0.0.0:2375
export VAULT_SERVER_CONTAINER_NAME='vaultdi'
#export VAULT_SERVER_CONTAINER_NAME='vaultsf'
#export VAULT_SERVER_CONTAINER_NAME='vaultsc'
export VAULT_CLIENT_WORK_DIR=$(pwd)/../vault-client-work-dir
function destroyContainers()
{
printf "***** Destroying containers\n"
local imageNameFilter=$1
printf "List of all containers before destruction\n"
docker ps -a
printf "Stopping and removing containers\n"
local toBeDestroyed=$(docker ps -a | tail -n +2 | grep $imageNameFilter | awk '{ print $1 }')
docker stop $toBeDestroyed > /dev/null
docker rm $toBeDestroyed > /dev/null
printf "List of all containers after destruction\n"
docker ps -a
}
function _interfaceIp()
{
local interfaceName=$1
ifconfig $interfaceName | grep inet | head -n 1 | awk '{print $2}'
}
function _dockerBridgeIp()
{
_interfaceIp docker0
}
function _usedInterfaceIp()
{
local interfaceName=$(ifconfig -a | grep $(netstat -i | tail -n +3 | awk '{print $1}' | grep -vE 'docker0|lo|veth') | sed 's@:.*@@')
_interfaceIp $interfaceName
}
function _containerIp()
{
local containerName=$1
docker inspect -f '{{.NetworkSettings.IPAddress}}' $containerName
}
function _printContainerNameAndIp()
{
local containerName=$1
printf "$containerName IP: $(_containerIp $containerName)\n\n"
}
function _printLogs()
{
local containerName=$1
docker logs $containerName 2>&1
}
source ./consul-standard.sh
source ./consul-template.sh
source ./vault-activate.sh
source ./vault-backend-secrets.sh
source ./vault-backend-security.sh
source ./vault-http-api.sh