Simple netcat (NC) persistent "listen" server running on Alpine Linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.7 KiB

### 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\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]\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 /bin/sh\n"
printf "\n--- end of help ---\n\n"
exec "$@"