forked from JasonGiedymin/docker-parallels-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot2dockerp
executable file
·160 lines (141 loc) · 2.9 KB
/
boot2dockerp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# Author: Jason Giedymin <jason dot giedymin -at- gmail dot com>
# License: Apache2
# Desc: Simple script to help drive the boot2docker docker with
# parallels without much change.
#
# Install:
# ./boot2dockerp install
# ./boot2dockerp env
# # Follow instructions of the env command
# docker ps # should now work
#
# Anytime you open a new shell, run:
# boot2dockerp env
#
# For ease of use, supply boot2dockerp somewhere on your path.
#
# Important Note:
# boot2docker has been deprecated in favor of docker-machine.
# Use the docker-machinep command which is part of this repo.
# https://github.com/JasonGiedymin/docker-parallels-helpers
set -e
# consider changing this var
BOOT2DOCKER_PARALLELS=($PWD)
function install() {
vagrant init parallels/boot2docker
vagrant up
vagrant ssh -c "sudo sh -c 'echo \"export DOCKER_TLS=no\" > /var/lib/boot2docker/profile'"
vagrant reload
vagrant halt
echo "boot2dockerp ready, see usage below:"
$0 usage
}
function install_old() {
cat <<EOF
------------------------------------------------------------
# Consider these instructions to allow this script to work
vagrant plugin install vagrant-parallels
cd ~ # or where you want to clone the boot2docker parallels box
mkdir ~/boot2docker-parallels
pushd ~/boot2docker-parallels
vagrant init parallels/boot2docker
vagrant up
vagrant ssh -c "sudo sh -c 'echo \"export DOCKER_TLS=no\" > /var/lib/boot2docker/profile'"
vagrant reload
vagrant halt
popd
# Modify the script var BOOT2DOCKER_PARALLELS to where the
# vagrantfile is.
# re-run this tool
$0 up
------------------------------------------------------------
EOF
}
function pre() {
echo "Preparing boot2docker parallels vm..."
pushd $BOOT2DOCKER_PARALLELS
}
function post() {
popd
}
function setEnv() {
unset DOCKER_TLS_VERIFY
export DOCKER_HOST="tcp://`vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp"`:2375"
}
function manualEnv() {
echo
echo "Please set the following in the current shell:"
echo " unset DOCKER_TLS_VERIFY"
echo " export DOCKER_HOST=$DOCKER_HOST"
echo
}
function dockerTest() {
sleep 2
time docker version
time docker ps
echo "Complete."
echo "See $BOOT2DOCKER_PARALLELS/README.md for instructions if errors occur."
}
function env() {
pre
setEnv
dockerTest
post
}
function status() {
pre
vagrant status
post
}
function up() {
pre
vagrant up
setEnv
dockerTest
post
}
function down() {
pre
vagrant halt
post
}
function destroy() {
pre
echo "Press any key to continue with destroy..."
read
post
}
function usage() {
cat <<EOF
$0 {up|down|halt|destroy|usage|env|install}
EOF
}
case "$1" in
up)
time up
;;
down|halt)
time down
;;
destroy)
destroy
;;
usage)
usage
;;
env)
env
manualEnv
;;
status)
status
;;
install)
install
;;
*)
echo "Command '$1' unknown."
usage
;;
esac