entrypoint.sh 477 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/bin/sh

set -e
### debugging
#echo "$@"
#set -ux

# run the entrypoint if one of the following conditions is true:
#  * the first parameter is an option (it begins with an '-')
#  * the first parameter is not a command found in PATH (i.e. "bash")
#  * the first parameter is a directory
#
if [ "${1#-}" != "${1}" ] || [ ! -x "$(command -v "${1}")" ] || [ -d "${1}" ]
then
  # reset the script parameters to the following commands
  set -- "${ENTRYPOINT}" "$@"
fi

exec "$@"