2021-01-29 03:18:30 +05:30
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
### Usage: /docker-entrypoint.sh <command> <args>
|
2021-02-04 21:13:00 +05:30
|
|
|
function main() {
|
|
|
|
executable=$1
|
|
|
|
command=$2
|
2021-01-30 16:24:17 +05:30
|
|
|
|
2021-02-04 21:13:00 +05:30
|
|
|
if [[ "$executable" != "dex" ]] && [[ "$executable" != "$(which dex)" ]]; then
|
|
|
|
exec $@
|
|
|
|
fi
|
2021-01-29 03:18:30 +05:30
|
|
|
|
2021-02-04 21:13:00 +05:30
|
|
|
if [[ "$command" != "serve" ]]; then
|
2021-01-29 03:18:30 +05:30
|
|
|
exec $@
|
2021-02-04 21:13:00 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
for tpl_candidate in $@ ; do
|
|
|
|
case "$tpl_candidate" in
|
|
|
|
*.tpl|*.tmpl|*.yaml)
|
|
|
|
tmp_file=$(mktemp /tmp/dex.config.yaml-XXXXXX)
|
|
|
|
gomplate -f "$tpl_candidate" -o "$tmp_file"
|
|
|
|
|
|
|
|
args="${args} ${tmp_file}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
args="${args} ${tpl_candidate}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
exec $args
|
|
|
|
}
|
|
|
|
|
|
|
|
main $@
|