-
Notifications
You must be signed in to change notification settings - Fork 0
/
drush.wrapper
executable file
·44 lines (37 loc) · 1.42 KB
/
drush.wrapper
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
#!/usr/bin/env bash
#
# DRUSH WRAPPER
# This wrapper script enables Drush to be seamlessly run inside of our PHP
# Docker container, using the locally installed Drush.
# You can find out more about Drush wrapper scripts from their repo in the
# examples folder.
# This wrapper has been tested with the following Drush commands.
# drush @docker status
# drush @docker status | tee file.txt
#
# drush @docker sql-cli
# echo "show tables" | drush @docker sql-cli
# echo "show tables" | drush @docker sql-cli | tee file.txt
script="$0"
basename="$(dirname $script)"
# Only running Drush on the docker container when it's being requested means
# that it is still possible to connect to remote services, because the Docker
# container doesn't have access to our ssh keys.
if [[ $@ == *"@docker"* ]]; then
CONTAINER=$(docker-compose ps -q php)
if [ -z "$CONTAINER" ]; then
>&2 echo "Error: Docker doesn't appear to be running, only remote commands will work at the moment."
exit 1
fi
ARGS="-i"
# For the case where no pipes are being used, opening a TTY makes
# interactions work properly.
if [ -t 0 -a -t 1 ]; then
ARGS="-it"
fi;
# Tell Docker the number of columns in our terminal.
ARGS="${ARGS} -e COLUMNS="`tput cols`
docker exec $ARGS $CONTAINER ./vendor/bin/drush --local --alias-path=/var/www/html/drush "$@"
else
${basename}/vendor/bin/drush --alias-path=./drush "$@"
fi