From 234c1d8f0e4035f746927c4df5bdc2d968c8cb36 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Fri, 30 Jun 2023 09:22:28 +0000 Subject: [PATCH] Enhancement: Enhance `/docker-entrypoint.sh` with `easyrsa` subcommand detection with fallback on binary --- generate/templates/docker-entrypoint.sh.ps1 | 22 +++++++++++++----- .../v3.0.1-alpine-3.3/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.1-alpine-3.4/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.1-alpine-3.5/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.1-alpine-3.6/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.3-alpine-3.7/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.4-alpine-3.8/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.5-alpine-3.9/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.6-alpine-3.10/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.6-alpine-3.11/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.7-alpine-3.12/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.0.8-alpine-3.13/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.1.1-alpine-3.17/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.1.2-alpine-3.18/docker-entrypoint.sh | 23 +++++++++++++------ .../v3.1.5-alpine-edge/docker-entrypoint.sh | 23 +++++++++++++------ 15 files changed, 240 insertions(+), 104 deletions(-) diff --git a/generate/templates/docker-entrypoint.sh.ps1 b/generate/templates/docker-entrypoint.sh.ps1 index 69b67e1..df28cd4 100644 --- a/generate/templates/docker-entrypoint.sh.ps1 +++ b/generate/templates/docker-entrypoint.sh.ps1 @@ -1,13 +1,23 @@ @' #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" exec "$@" + '@ diff --git a/variants/v3.0.1-alpine-3.3/docker-entrypoint.sh b/variants/v3.0.1-alpine-3.3/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.1-alpine-3.3/docker-entrypoint.sh +++ b/variants/v3.0.1-alpine-3.3/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.1-alpine-3.4/docker-entrypoint.sh b/variants/v3.0.1-alpine-3.4/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.1-alpine-3.4/docker-entrypoint.sh +++ b/variants/v3.0.1-alpine-3.4/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.1-alpine-3.5/docker-entrypoint.sh b/variants/v3.0.1-alpine-3.5/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.1-alpine-3.5/docker-entrypoint.sh +++ b/variants/v3.0.1-alpine-3.5/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.1-alpine-3.6/docker-entrypoint.sh b/variants/v3.0.1-alpine-3.6/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.1-alpine-3.6/docker-entrypoint.sh +++ b/variants/v3.0.1-alpine-3.6/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.3-alpine-3.7/docker-entrypoint.sh b/variants/v3.0.3-alpine-3.7/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.3-alpine-3.7/docker-entrypoint.sh +++ b/variants/v3.0.3-alpine-3.7/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.4-alpine-3.8/docker-entrypoint.sh b/variants/v3.0.4-alpine-3.8/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.4-alpine-3.8/docker-entrypoint.sh +++ b/variants/v3.0.4-alpine-3.8/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.5-alpine-3.9/docker-entrypoint.sh b/variants/v3.0.5-alpine-3.9/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.5-alpine-3.9/docker-entrypoint.sh +++ b/variants/v3.0.5-alpine-3.9/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.6-alpine-3.10/docker-entrypoint.sh b/variants/v3.0.6-alpine-3.10/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.6-alpine-3.10/docker-entrypoint.sh +++ b/variants/v3.0.6-alpine-3.10/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.6-alpine-3.11/docker-entrypoint.sh b/variants/v3.0.6-alpine-3.11/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.6-alpine-3.11/docker-entrypoint.sh +++ b/variants/v3.0.6-alpine-3.11/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.7-alpine-3.12/docker-entrypoint.sh b/variants/v3.0.7-alpine-3.12/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.7-alpine-3.12/docker-entrypoint.sh +++ b/variants/v3.0.7-alpine-3.12/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.0.8-alpine-3.13/docker-entrypoint.sh b/variants/v3.0.8-alpine-3.13/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.0.8-alpine-3.13/docker-entrypoint.sh +++ b/variants/v3.0.8-alpine-3.13/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.1.1-alpine-3.17/docker-entrypoint.sh b/variants/v3.1.1-alpine-3.17/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.1.1-alpine-3.17/docker-entrypoint.sh +++ b/variants/v3.1.1-alpine-3.17/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.1.2-alpine-3.18/docker-entrypoint.sh b/variants/v3.1.2-alpine-3.18/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.1.2-alpine-3.18/docker-entrypoint.sh +++ b/variants/v3.1.2-alpine-3.18/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@" diff --git a/variants/v3.1.5-alpine-edge/docker-entrypoint.sh b/variants/v3.1.5-alpine-edge/docker-entrypoint.sh index 3d6fa44..2790529 100644 --- a/variants/v3.1.5-alpine-edge/docker-entrypoint.sh +++ b/variants/v3.1.5-alpine-edge/docker-entrypoint.sh @@ -1,11 +1,20 @@ #!/bin/sh +set -eu -set -aeo pipefail +if [ $# -gt 0 ]; then + # Get all subcommands. 'help' is also a subcommand + SUBCOMMANDS=$( ./easyrsa | awk "/^'help'/,/^DIRECTORY/" | grep -vE "^'help'|^DIRECTORY|^\s*$" | awk '{print $1}'; echo help ) + if echo "$SUBCOMMANDS" | grep "^$1$"; then + # Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md + echo "Generating command line" + set "$EASYRSA/easyrsa" "$@" -# Generate the command line. easy-rsa man: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/README.quickstart.md -echo "Generating command line" -set "$EASYRSA/easyrsa" "$@" + # Exec + echo "easyrsa command line: $@" + exec "$@" + fi +else + exec "$EASYRSA/easyrsa" "$@" +fi -# Exec -echo "easyrsa command line: $@" -exec "$@" \ No newline at end of file +exec "$@"