forked from d2iq-archive/dcos-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-dcos-docker.sh
executable file
·70 lines (55 loc) · 2.28 KB
/
get-dcos-docker.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
#!/bin/bash
# Launches a DC/OS dev environment based containing a running 3-agent cluster and dev tools.
#
# Prerequisites:
# - 8GB RAM
# - Vagrant
# - Virtualbox
#
# Arguments:
# - BOX_PATH: Local path to use for .box image (useful if installing from USB stick)
# capture anonymous metrics for reporting
curl https://mesosphere.com/wp-content/themes/mesosphere/library/images/assets/sdk/create-dev-env-start.png >/dev/null 2>&1
# abort script at first error:
set -e
BOX_NAME=mesosphere/dcos-docker-sdk
error_msg() {
echo "---"
echo "Failed to build the cluster: Exited early at $0:L$1"
echo "To try again, re-run this script."
echo "---"
}
trap 'error_msg ${LINENO}' ERR
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR
cd tools/vagrant/
VAGRANT_DIR=$(pwd)
# Image-on-USB-stick scenario: Manually add the provided .box file directly
if [ $(vagrant box list | grep $BOX_NAME | wc -l) -eq 0 ]; then
if [ -n "$BOX_PATH" ]; then
echo "### Installing provided local box image as $BOX_NAME: $BOX_PATH"
vagrant box add --name $BOX_NAME ${BOX_PATH}
fi
elif [ -n "$BOX_PATH" ]; then
echo "### NOTICE: Local box image was provided, but vagrant already has a box named $BOX_NAME. Ignoring provided image: $BOX_PATH"
fi
echo "### Destroying pre-existing VM, if any"
vagrant destroy # intentionally allowing confirmation prompt in case the user didn't actually want to do this
echo "### Bringing up VM"
vagrant up
echo "### Starting DC/OS environment within VM"
vagrant ssh -c "/home/vagrant/start-dcos.sh"
echo "### Waiting for cluster to finish coming up"
vagrant ssh -c "docker exec -i dcos-docker-master1 dcos-postflight"
${SCRIPT_DIR}/node-route.sh
echo "----"
echo "Dashboard URL: http://172.17.0.2"
echo ""
echo "Log into VM: pushd ${VAGRANT_DIR} && vagrant ssh && popd"
echo "Build example: Log into VM, then: cd /dcos-commons/frameworks/helloworld && ./build.sh local"
echo ""
echo "Repair routes: ${SCRIPT_DIR}/node-route.sh # (use this if VM connectivity is lost)"
echo "Delete VM/data: pushd ${VAGRANT_DIR} && vagrant destroy && vagrant box remove $BOX_NAME && popd"
echo "---"
# capture anonymous metrics for reporting
curl https://mesosphere.com/wp-content/themes/mesosphere/library/images/assets/sdk/create-dev-env-finish.png >/dev/null 2>&1