-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_project
executable file
·72 lines (61 loc) · 1.56 KB
/
run_project
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
#!/bin/bash
read -r -d '' HELP<<'ENDHELP'
run_project
Start an instance of the 4DGB Browser for a project.
Usage:
./run_project [-h|--help] [-|--port PORT] [-n|--name NAME] PROJECT_DIRECTORY
Options:
-h, --help: View this help and exit
-n, --name: Set the name for the project
(defaults to the name of the project directory)
-p, --port: Set the port for the server to run on.
(default: 8000)
Arguments:
PROJECT_DIRECTORY: Directory containing the project
(and project.json)
ENDHELP
# Reset IFS (newline, tab, space)
IFS='
'
set -eu
PORT=8000
PROJECT=""
NAME_OVERRIDE=""
while [ "$#" -gt 0 ] ; do
case "$1" in
-h|--help)
echo "$HELP"
exit
;;
-p|--port)
shift
PORT="$1"
;;
-n|--name)
shift
NAME_OVERRIDE="yes"
NAME="$1"
;;
-*)
echo "unrecognized option: $1"
;;
*)
PROJECT="$1"
;;
esac
shift
done
if [ -z "$PROJECT" ] ; then
echo "No project specified." 1>&2
echo "Usage: ./run_project [-|--port PORT] [-h|--help] PROJECT_DIRECTORY" 1>&2
exit 1
fi
PROJECT="$(realpath "$PROJECT")"
if [ -z "$NAME_OVERRIDE" ] ; then
NAME="$(basename "$PROJECT")"
fi
docker run --rm -it \
-p "127.0.0.1:$PORT:80" \
-v "$PROJECT:/project:ro" \
-v "4dgbprojects:/srv/release" \
4dgbrunner "$NAME" "$PORT"