Compare commits

...

2 Commits

Author SHA1 Message Date
Asif Bacchus c5ab25c706 update cmd label to point to help cmd 2020-02-07 07:23:31 -07:00
Asif Bacchus 68cb4e425f add built-in help 2020-02-07 07:23:23 -07:00
2 changed files with 24 additions and 2 deletions

View File

@ -5,7 +5,7 @@ FROM alpine:3.11
# standardized labels
LABEL maintainer="Asif Bacchus <asif@bacchus.cloud>"
LABEL org.label-schema.cmd="docker run [-d|-it] --init --rm -p [<ipaddr>:]<host port>:5555 [--name ab-netcat] [-e TZ=timezone] docker.asifbacchus.app/ab-netcat [/bin/sh]"
LABEL org.label-schema.cmd="docker run --rm docker.asifbacchus.app/ab-netcat help"
LABEL org.label-schema.description="Persistent netcat (BSD) echo server on Alpine Linux"
LABEL org.label-schema.name="ab-netcat"
LABEL org.label-schema.schema-version="1.0"

View File

@ -4,6 +4,28 @@
### run supplied CMD
#
exec "$@"
convertCase () {
printf "%s" "$1" | tr "[:upper:]" "[:lower:]"
}
# check if requesting help
isHELP=$( convertCase "$1" )
if [ "$isHELP" = 'help' ]; then
# display help
printf "\n\n--- ab-netcat usage ---\n\n"
printf "This container can be run in several ways, more details in the repo wiki at https://git.asifbacchus.app/ab-docker/ab-netcat/wiki\n\n"
printf "In all cases, this container is a persistent listener. General execution is:\n"
printf "docker run [-d|-it] --init --rm -p [<ipaddr>:]<host port>:5555 [--name ab-netcat] [-e TZ=timezone] docker.asifbacchus.app/ab-netcat\n\n"
printf "neither '-d' or '-it': Run in the foreground and display what's being received.\n\n"
printf "'-d': Run detached, you will have to run 'docker logs -f ab-netcat' to see what the container is receiving from connected client(s).\n\n"
printf "'-it': Run interactively. You can respond to clients or even chat :-)\n\n"
printf "'--init': This allows you to use ctrl-c to terminate container instead of having to run 'docker stop ab-netcat' or 'docker rm -f ab-netcat'. Only useful when running in the foreground or interactively.\n\n"
printf "'-e TZ=timezone': The container will default to UTC time, but you can change it using this environment variable. Ex: '-e TZ=America/Edmonton'\n\n"
printf "You can run the container and supply '/bin/sh' after the container name if you want to be dumped to a shell instead of automatically running netcat. If you're doing that, remember to also pass '-it':\n"
printf "Ex: docker run -it --rm -p 127.0.0.1:5555:5555 docker.asifbacchus.app/ab-netcat /bin/sh\n"
printf "\n--- end of help ---\n\n"
else
exec "$@"
fi
#EOF