-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·68 lines (55 loc) · 1.74 KB
/
start.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
#!/usr/bin/env bash
# Shell script necessary to initialize x11docker before starting containers
# with Docker Compose. See https://github.com/mviereck/x11docker/issues/227
set -o errexit
set -o nounset
set -o pipefail
function exit_handler {
if [ "$must_cleanup_x11docker" = true ]; then
echo "Cleaning up x11docker"
x11docker --cleanup --quiet
fi
}
must_cleanup_x11docker=false
trap exit_handler EXIT
function print_usage {
echo "Usage: $(basename $0) [-h] {drone|argos|build}"
}
function print_help {
print_usage
echo
echo "Hivexplore - mapping rooms with drone swarms!"
echo
echo "Command:"
echo " drone use the Crazyradio to connect to Crazyflies"
echo " argos use ARGoS to simulate the drones"
echo " build rebuild all Docker images"
}
if [ "$#" -ne 1 ]; then
if [ "$#" -eq 0 ]; then
echo "Missing command argument"
else
echo "Too many arguments"
fi
print_usage
exit 1
fi
case "$1" in
-h|--help) print_help; exit;;
drone|argos|build) mode="$1";;
*) echo "Unknown argument '$1'"; print_usage; exit 1;;
esac
function initialize_x11docker {
must_cleanup_x11docker=true
echo "Initializing x11docker"
read x_env < <(x11docker --hostdisplay --showenv --quiet)
export $x_env
}
readonly BASE_FILE="docker-compose.yml"
readonly DRONE_OVERRIDE_FILE="docker-compose.drone.yml"
readonly ARGOS_OVERRIDE_FILE="docker-compose.argos.yml"
case "$mode" in
drone) docker-compose -f "$BASE_FILE" -f "$DRONE_OVERRIDE_FILE" up;;
argos) initialize_x11docker; docker-compose -f "$BASE_FILE" -f "$ARGOS_OVERRIDE_FILE" up;;
build) docker-compose -f "$BASE_FILE" -f "$DRONE_OVERRIDE_FILE" -f "$ARGOS_OVERRIDE_FILE" build;;
esac