-
Notifications
You must be signed in to change notification settings - Fork 0
/
doev
executable file
·74 lines (65 loc) · 2.05 KB
/
doev
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
#!/usr/bin/env bash
# TODO:
# regenerate certificates if needed
# normal arguments parsing
# error message for certificates:
# Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": tls: DialWithDialer timed out
# You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
# Be advised that this will trigger a Docker daemon restart which might stop running containers.
LOG_FILE="/tmp/.doev_logs_"`date +%Y%m%d%H%M%S`
function help
{
echo "Few useful things for forgetful / lazy Docker users"
echo "Usage:"
echo " . $(basename $0) machine_name - switch to docker-machine machine_name content"
echo " $(basename $0) which - prints currently used docker-machine"
echo " $(basename $0) - runs: docker-machine ls"
exit 0
}
if [ "${1}" = "which" ]; then
denv_res=`env | grep DOCKER_MACHINE_NAME`
IFS='='
denv=(${denv_res})
echo "docker-machine: ${denv[1]}"
exit 0
fi
if [ "${1}" = "help" ]; then
help
fi
if [ "${1}" != "" ]; then
if [ "${0}" != "-bash" ]; then
echo "It looks like you forgot to source file!"
echo "Help:"
help
fi
echo 'eval "$(docker-machine env '${1}')"'
touch ${LOG_FILE}
eval "$(docker-machine env ${1})" 2>&1 | tee -a ${LOG_FILE} #just for catching issues
eval "$(docker-machine env ${1})"
TEST=`grep Host ${LOG_FILE}`
echo $TEST
rm ${LOG_FILE}
if [ ! -z "`echo $LOGS | grep regenerate-certs`" ]; then
echo "regenerating certificates"
echo "docker-machine regenerate-certs ${1}"
docker-machine regenerate-certs ${1}
elif [ ! -z "`echo $LOGS | grep exist`" ]; then
exit -1
fi
else
echo "Empty docker-machine name, listing machines"
echo "For help type: $(basename $0) help"
docker-machine ls
exit -1
fi
ENV_RES=`env | grep DOCKER_MACHINE_NAME`
IFS='='
KEY_VALUE=($ENV_RES)
if [ "${1}" != "${KEY_VALUE[1]}" ]
then
echo "docker-machine not set!"
echo "parameter: _${1}_"
echo "value: _${KEY_VALUE[1]}_"
else
echo "using machine ${1}"
fi