#!/bin/bashset -euo pipefail
# Check if the the user has invoked the image with flags.# eg. "apm-server -c apm-server.yml"if[[ -z $1]]||[[${1:0:1}=='-']];thenexec apm-server "$@"else# They may be looking for a Beat subcommand, like "apm-server setup".
subcommands=$(apm-server help \
|awk'BEGIN {RS=""; FS="\n"} /Available Commands:/' \
|awk'/^\s+/ {print $1}')# If we _did_ get a subcommand, pass it to apm-server.for subcommand in$subcommands;doif[[$1==$subcommand]];thenexec apm-server "$@"fidonefi# If neither of those worked, then they have specified the binary they want, so# just do exactly as they say.exec"$@"