#!/bin/sh # ### run supplied CMD # 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 [:]: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