-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-caravan.sh
executable file
·91 lines (77 loc) · 2.85 KB
/
setup-caravan.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
# This script assumes you are running this file from the repository root directory.
# For example, /var/www/se3_blt
# Setup config file paths
BEHAT_DEFAULT_CONFIG="vendor/su-sws/drupal-caravan/config/behat.yml"
DRUPALVM_CONFIG="vendor/su-sws/drupal-caravan/config/caravan.yml"
DRUSH_ALIAS="vendor/su-sws/drupal-caravan/config/caravan.aliases.drushrc.php"
# Bake a Docker container with Drupal VM.
# Exit on any individual command failure.
set -e
# Set variables.
DRUPALVM_IP_ADDRESS="${DRUPALVM_IP_ADDRESS:-192.168.88.88}"
DRUPALVM_MACHINE_NAME="${DRUPALVM_MACHINE_NAME:-earth}"
DRUPALVM_HOSTNAME="${DRUPALVM_HOSTNAME:-earth.local}"
DRUPALVM_PROJECT_ROOT="${DRUPALVM_PROJECT_ROOT:-/var/www/earth}"
DRUPALVM_HTTP_PORT="${DRUPALVM_HTTP_PORT:-9000}"
DRUPALVM_HTTPS_PORT="${DRUPALVM_HTTPS_PORT:-9001}"
DISTRO="${DISTRO:-ubuntu1604}"
OPTS="${OPTS:---privileged}"
INIT="${INIT:-/lib/systemd/systemd}"
# Helper function to colorize statuses.
function status() {
status=$1
printf "\n"
echo -e -n "\033[32m$status"
echo -e '\033[0m'
}
# Set volume options.
if [[ "$OSTYPE" == "darwin"* ]]; then
volume_opts='rw,cached'
else
volume_opts='rw'
fi
# Run the container.
status "Bringing up Docker container..."
if [ "$ENVIRONMENT" == "travis" ]; then
docker run --name=$DRUPALVM_MACHINE_NAME -d \
--add-host "$DRUPALVM_HOSTNAME":127.0.0.1 \
-v $PWD:$DRUPALVM_PROJECT_ROOT/:$volume_opts \
$OPTS \
geerlingguy/docker-$DISTRO-ansible:latest \
$INIT
else
docker run --name=$DRUPALVM_MACHINE_NAME -d \
--add-host "$DRUPALVM_HOSTNAME":127.0.0.1 \
-v $PWD:$DRUPALVM_PROJECT_ROOT/:$volume_opts \
-p $DRUPALVM_IP_ADDRESS:$DRUPALVM_HTTP_PORT:80 \
-p $DRUPALVM_IP_ADDRESS:$DRUPALVM_HTTPS_PORT:443 \
-v $HOME/.ssh/acquia_id_rsa:/root/.ssh/id_rsa \
-v $HOME/.ssh/acquia_id_rsa.pub:/root/.ssh/id_rsa.pub \
$OPTS \
geerlingguy/docker-$DISTRO-ansible:latest \
$INIT
fi
# Create Drupal directory.
docker exec $DRUPALVM_MACHINE_NAME mkdir -p $DRUPALVM_PROJECT_ROOT
# Set things up and run the Ansible playbook.
status "Running setup playbook..."
docker exec --tty $DRUPALVM_MACHINE_NAME env TERM=xterm \
ansible-playbook $DRUPALVM_PROJECT_ROOT/vendor/geerlingguy/drupal-vm/tests/test-setup.yml
status "Provisioning Drupal VM inside Docker container..."
docker exec $DRUPALVM_MACHINE_NAME env TERM=xterm ANSIBLE_FORCE_COLOR=true \
DRUPALVM_ENV=acquia \
ansible-playbook $DRUPALVM_PROJECT_ROOT/vendor/su-sws/drupal-caravan/provisioning/playbook.yml
status "...done!"
status "Visit the Drupal VM dashboard: http://$DRUPALVM_IP_ADDRESS:$DRUPALVM_HTTP_PORT"
# Do not run in continuous integration environments
if [ -z "$ENVIRONMENT" ]; then
read -p "Would you like to log into the test environment? Yes to login, No to quit. " -n 1 -r
echo "\n"
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker exec -it $DRUPALVM_MACHINE_NAME bash
else
exit
fi
fi