-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
87 lines (70 loc) · 1.77 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# Environment
INPUT_TYPE="${INPUT_TYPE:-auto}"
INPUT_CONNECT_HOST="${INPUT_CONNECT_HOST:-}"
INPUT_CONNECT_PORT="${INPUT_CONNECT_PORT:-30002}"
INPUT_CONNECT="${INPUT_CONNECT_HOST}:${INPUT_CONNECT_PORT}"
RESULTS="${RESULTS:-}"
NO_ANON_RESULTS="${NO_ANON_RESULTS:-no}"
NO_MODEAC_RESULTS="${NO_MODEAC_RESULTS:-no}"
LAT="${LAT:-}"
LON="${LON:-}"
ALT="${ALT:-}"
PRIVACY="${PRIVACY:-no}"
USER="${USER:-}"
SERVER_HOST="${SERVER_HOST:-feed.adsbexchange.com}"
SERVER_PORT="${SERVER_PORT:-31090}"
SERVER="${SERVER_HOST}:${SERVER_PORT}"
NO_UDP="${NO_UDP:-no}"
UUID_FILE="${UUID_FILE:-}"
UUID="${UUID:-}"
LOG_TIMESTAMPS="${LOG_TIMESTAMPS:-no}"
# Validate
if [ -z "$INPUT_TYPE" ] || [ -z "$INPUT_CONNECT_HOST" ] || [ -z "$INPUT_CONNECT_PORT" ] || [ -z "$LAT" ] || [ -z "$LON" ] || [ -z "$ALT" ] || [ -z "$USER" ] || [ -z "$SERVER_HOST" ] || [ -z "$SERVER_PORT" ]
then
>&2 echo "Required environment variables are empty. Exiting..."
sleep 3
exit 1
fi
# Command
ARGS="--input-type ${INPUT_TYPE} --input-connect ${INPUT_CONNECT} --lat ${LAT} --lon ${LON} --alt ${ALT} --user ${USER} --server ${SERVER}"
if [ ! -z "$RESULTS" ]
then
ARGS="${ARGS} --results ${RESULTS}"
fi
if [ "$NO_ANON_RESULTS" = "yes" ]
then
ARGS="${ARGS} --no-anon-results"
fi
if [ "$NO_MODEAC_RESULTS" = "yes" ]
then
ARGS="${ARGS} --no-modeac-results"
fi
if [ "$PRIVACY" = "yes" ]
then
ARGS="${ARGS} --privacy"
fi
if [ "$NO_UDP" = "yes" ]
then
ARGS="${ARGS} --no-udp"
fi
if [ ! -z "$UUID_FILE" ]
then
ARGS="${ARGS} --uuid-file ${UUID_FILE}"
fi
if [ ! -z "$UUID" ]
then
ARGS="${ARGS} --uuid ${UUID}"
fi
if [ "$LOG_TIMESTAMPS" = "yes" ]
then
ARGS="${ARGS} --log-timestamps"
fi
# Execute
CMD=()
for i in "$@"
do
CMD+=("$i")
done
CMD[${#CMD[@]}-1]="${CMD[-1]} $ARGS"
exec "${CMD[@]}"