-
Notifications
You must be signed in to change notification settings - Fork 40
/
beaker
executable file
·37 lines (28 loc) · 1.17 KB
/
beaker
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
#!/usr/bin/env bash
# Change dir to script dir
pushd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" > /dev/null
# If the current user doesn't have docker permissions or
# permission to open the env file, use sudo
SUDO=
if [ ! -w "/var/run/docker.sock" -o ! -r ".env" ]; then
SUDO="sudo --preserve-env"
fi
# Check for pre-requisites
shell-lib/docker/check_docker.sh || echo "You do not have a supported version of Docker installed."
shell-lib/docker/check_docker-compose.sh || echo "You do not have a supported version of Docker-Compose installed."
# Ensure docker-compose can write to a temporary directory and execute scripts there
source ./shell-lib/acmlib.sh
require_executable_tmp_dir
# TMPDIR is erased even if -E is passed to sudo. https://serverfault.com/questions/478741/sudo-does-not-preserve-tmpdir
# Need to explicitly pass tmpdir in if it exists.
if [ -n "$TMPDIR" ]; then
$SUDO env "TMPDIR=$TMPDIR" docker-compose -f "docker-compose.yml" "$@"
else
$SUDO docker-compose -f "docker-compose.yml" "$@"
fi
# Store the exit code from docker-compose to use later
result=$?
# Change back to original directory
popd > /dev/null
# Pass docker-compose's exit code through
exit $result