-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·55 lines (44 loc) · 929 Bytes
/
entrypoint.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
#!/bin/sh
set -eu
# copied from build/erlang-shipment/entrypoint.sh
PACKAGE=hello_world
BASE=$(dirname "$0")
COMMAND="${1-default}"
run() {
ERL_ARGS=""
# expand ERL_XARGS environment variable eval to support env vars like $HOST
if [ -n "${ERL_XARGS-}" ]; then
ERL_ARGS=$(eval echo "$ERL_XARGS")
fi
# add -setcookie if COOKIE is set
if [ -n "${COOKIE-}" ]; then
ERL_ARGS="$ERL_ARGS -setcookie $COOKIE"
fi
echo "ERL_ARGS: $ERL_ARGS"
erl \
-pa "$BASE"/*/ebin \
-eval "$PACKAGE@@main:run($PACKAGE)" \
-noshell \
$ERL_ARGS \
-extra "$@"
}
shell() {
erl -pa "$BASE"/*/ebin
}
case "$COMMAND" in
run)
shift
run "$@"
;;
shell)
shell
;;
*)
echo "usage:" >&2
echo " entrypoint.sh \$COMMAND" >&2
echo "" >&2
echo "commands:" >&2
echo " run Run the project main function" >&2
echo " shell Run an Erlang shell" >&2
exit 1
esac